qq_32763435
qq_32763435
2015-11-19 02:10

新手学SpringMvc存储session的问题

  • spring
  • session

@Controller
@SessionAttributes("user")
public class UserController {
@Resource
private UserService userService;
@RequestMapping("/login")
public ModelAndView getLogin( User user,ModelMap model,HttpServletRequest request, HttpServletResponse response) {
ModelAndView mav = new ModelAndView("login");
String userName = request.getParameter("uname").trim();
String userPassword = request.getParameter("upass").trim();
System.err.println("用户名和密码" + userName + userPassword);
User user1= userService.selectLogin(userName, userPassword);
model.addAttribute("user",user1);
User uuser=(User)request.getSession().getAttribute("user");
System.out.println("管理用户邮箱/密码"+uuser.getUserEmail()+uuser.getUserName());
return mav;
}
}

为什么会获取不到session呢?
应该怎样做修改呢?

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答

为你推荐