需要修改两个地方
- 1 login.jsp
- 2 login.do
1 login.jsp
2 login.do
在login.jsp中添加代码
- String referer = request.getHeader("Referer");
- session.setAttribute("returnURL", referer);
String referer = request.getHeader("Referer");
session.setAttribute("returnURL", referer);
记录登陆前页面url
login.do 从session中取得returnURL ,然后跳转
- if( loginSuccess ){
- String returnURL = (String)request.getSession().getAttribute("returnURL");
- response.sendRedirect(returnURL );
- }
if( loginSuccess ){
String returnURL = (String)request.getSession().getAttribute("returnURL");
response.sendRedirect(returnURL );
}
呵呵 就这么简单轻松搞定
对了最后别忘了session.removeAttribute(returnURL);