jsp页面无法获取action传来的session
//登录
public ActionForward doLogin(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)throws IOException {
UserForm userForm = (UserForm) form;
UserInfo ui=userForm.getUserInfo();
ui=ub.login(ui.getDyzh(), ui.getPwd());
session=request.getSession();
session.setAttribute("current_user", ui);
request.setAttribute("if_user", "yes");
return mapping.findForward("updatePwd");
}
//修改密码
public ActionForward doUpdatePwd(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)throws IOException
{
UserForm userForm = (UserForm) form;
UserInfo ui=userForm.getUserInfo();
UserInfo ui2=ub.getUserByNamePwd(ui.getDyzh(), ui.getPwd());
ub.updatePwd(ui.getDyzh(), ui.getNewPwd());
ub.updateState(ui.getDyzh(),1);
UserInfo ui3=(UserInfo)session.getAttribute("current_user");
ui3.setPwd(ui.getNewPwd());
ui3.setState(1);
session.setAttribute("current_user", ui3);
return mapping.findForward("main");
}
上面两个方法是action里的方法,由上可知:
在登录方法里,我创建了session.setAttribute("current_user", ui);
在修改密码方法里,我为session赋了新值session.setAttribute("current_user", ui3);
然后转发到main.jsp页面:return mapping.findForward("main");
可是我在main.jsp页面里却无法获得session:session.getAttribute("current_user")
为什么?