关于SPRING管理HTTPSESSION
我对SPRING不是特别熟悉。
现在在用SPRING写点东西的时候遇到个问题,代码是这样的
@RequestMapping(value="/login",method=RequestMethod.POST)
public ModelAndView login(HttpServletRequest request){
ModelAndView mav = new ModelAndView("main/main");
String password = request.getParameter("password");
String login_name = request.getParameter("login_name");
if("admin".equals(login_name) && "admin".equals(password)){
HttpSession httpsession = request.getSession();
httpsession.setAttribute("user", login_name);
}
String path = request.getContextPath();
mav.addObject("path", path);
return mav;
}
登陆成功后到一个JSP页面可以获得HTTPSESSION,可是再跳转到另一个JSP页面的时候,就获得不到HTTPSESSION了,请哪位大侠指点一下
@RequestMapping(value="/to_other",method=RequestMethod.GET)
public ModelAndView to_other(HttpServletRequest request){
ModelAndView mav = new ModelAndView("main/other");
UserForm uf = new UserForm();
mav.addObject("uf", uf);
String path = request.getContextPath();
mav.addObject("path", path);
HttpSession httpsession = request.getSession();
httpsession.getAttribute("user");//null
return mav;
}