问一下关于struts的JSP中跳转到自己的问题
这个是关于login的struts的配置。
<action
attribute="loginForm"
name="loginForm"
parameter="method"
path="/login"
scope="session"
type="org.springframework.web.struts.DelegatingActionProxy">
<forward name="register" path="/JSP/register.jsp" />
<forward name="error" path="/JSP/login.jsp" redirect="true"/>
<forward name="success" path="/JSP/success.jsp" />
</action>
这个是LoginAction
if(userService.validate(username, userpass)) {
request.setAttribute("username", username + " " + aaa);
request.setAttribute("error", "OK");
actionPath = "success";
}
else {
request.setAttribute("error", "error");
actionPath = "error";
}
奇怪的是,当成功登录时,转到success.jsp,success.jsp可以正确得到request里面的username属性,并显示。
而当登录失败时,跳转路径是自己,自己却不能得到它的error值,必须要在上面把scope设为session,
下面用session.getAttribute才能得到,这是为什么?
为什么request里面的东西转发回自己就丢掉了?
另,那个redirect是什么作用?我只是乱加的,好像在这里没有作用。
<action
attribute="loginForm"
name="loginForm"
parameter="method"
path="/login"
scope="session"
type="org.springframework.web.struts.DelegatingActionProxy">
<forward name="register" path="/JSP/register.jsp" />
<forward name="error" path="/JSP/login.jsp" redirect="true"/>
<forward name="success" path="/JSP/success.jsp" />
</action>
这个是LoginAction
if(userService.validate(username, userpass)) {
request.setAttribute("username", username + " " + aaa);
request.setAttribute("error", "OK");
actionPath = "success";
}
else {
request.setAttribute("error", "error");
actionPath = "error";
}
奇怪的是,当成功登录时,转到success.jsp,success.jsp可以正确得到request里面的username属性,并显示。
而当登录失败时,跳转路径是自己,自己却不能得到它的error值,必须要在上面把scope设为session,
下面用session.getAttribute才能得到,这是为什么?
为什么request里面的东西转发回自己就丢掉了?
另,那个redirect是什么作用?我只是乱加的,好像在这里没有作用。
...全文
相关推荐
JSP开发答疑200问
专家门诊-JSP开发答疑200问 专家门诊-JSP开发答疑200问 专家门诊-JSP开发答疑200问
JSP开发200问
JSP开发200问<br>众多案例详细讲解
struts1直接跳转到jsp-无action的url
NULL 博文链接:https://fsh430623.iteye.com/blog/1328665
struts2 中路径无法跳转的问题
NULL 博文链接:https://lishouxinghome.iteye.com/blog/1364946
ajax 提交数据到后台jsp页面及页面跳转问题
ajax 提交数据到后台jsp页面及页面跳转问题 我logincheck.jsp页面取传参数代码: String user=request.getParameter("user1"); String pwd=request.getParameter("pwd1"); login.jsp input 取2参数何用ajax 传给logincheck.jsp $.ajax({ type : "POST", url : baseUrl+"m/module/querymodulebyname.do", dataType:"json", data: { modName:title }, succes


Web 开发
