struts2 动态重定向

@Override
public String list() throws Exception {
HttpServletRequest request = ServletActionContext.getRequest();
String loginName = request.getParameter("j_username"); 
String password = request.getParameter("j_password");
HttpSession session = request.getSession();
session.setAttribute("username", loginName); 
session.setAttribute("password", password);
//你要转向的页面的地址. 

String url = new String( ("../j_spring_security_check?j_username="
+java.net.URLEncoder.encode(loginName)
+"&j_password="+password).getBytes("UTF-8"),"ISO8859_1"); 

    //你要转向的页面的地址. 
HttpServletResponse response = ServletActionContext.getResponse();
response.sendRedirect(url); 
//重定向后,别忘了返回null值,而不能再返回return     

    //mapping.findForward("****");       
    return null;
//return SUCCESS;            

}

你可能感兴趣的:(struts2 动态重定向)