struts2的配置
struts.xml核心配置
package name="app" extends="struts-default" namespace="/">
<!-- app/模块/类名/方法名 -->
<action name="app/*/*/*" class="com.demo.app.{1}.action.{2}Action"
method="{3}">
<result name="defaultView">app/index/index/{3}.jsp</result>
<result name="view">/WEB-INF/jsp/{1}/{2}/${nextPath}.jsp</result>
</action>
</package>
Action调用方法,访问的uri=app/index/index/login
/* public String login(ServletRequest request,ServletResponse response){ */
public String login() throws NoSuchAlgorithmException, UnsupportedEncodingException{
HttpServletRequest request = ServletActionContext.getRequest();
HttpServletResponse response = ServletActionContext.getResponse();
logger.info("action_uri=="+request.getRequestURI());
HttpSession session = request.getSession();
User userExsit = (User) session.getAttribute("user");
if (userExsit != null) {
return view("recruitDetail");
} else {
String loginname = request.getParameter("mobile");
String password = request.getParameter("password");
User us = loginService.findByUserName(loginname);
if (us != null && us.getLoginPwd() != null && MD5Util.validPasswd(password, us.getLoginPwd())) {
return view("recruitDetail");-----------(成功执行这条语句,且struts.xml中的${nextPath}值为recruitDetail)
} else {
return view("login");
}
}
}
return 语句用到的view()方法
public String view(String vPath){
nextPath = vPath;
logger.debug("动作完成后,转发到:" + nextPath);
this.assign("timeStr",
"" + System.currentTimeMillis() + System.nanoTime());
this.assign("uuid", UUIDUtil.get32ID());// 为页面传递UUID,用于页面的标识
return "view";
}
结果是,我点击登陆后,在调试页面获得了要跳转页面如图:
我的问题是要跳转的页面已经可以在页面debug中查到,说明访问路径没问题,怎么就没有将原来的页面覆盖掉呢,请大神们帮忙解答下,小弟谢谢了,纠结半天了