@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呢?
應該怎樣做修改呢?
可以在參數中直接傳入session,然後直接使用