I am using Spring 3.2.0 MVC. In that i have to store one object to session. Currently i am using HttpSession set and get attribute to store and retive the value. It returns only the String not Object. I want to use @SessionAttribute when i tried it sets the object in session but i could not retrieve the session object
@RequestMapping(value = "/sample-login", method = RequestMethod.POST)
public String getLoginClient(HttpServletRequest request,ModelMap modelMap) {
String userName = request.getParameter("userName");
String password = request.getParameter("password");
User user = sample.createClient(userName, password);
modelMap.addAttribute("userObject", user);
return "user";
}
@RequestMapping(value = "/user-byName", method = RequestMethod.GET)
public
@ResponseBody
String getUserByName(HttpServletRequest request,@ModelAttribute User user) {
String fas= user.toString();
return fas;
}
both methods are in same controller. How would i use this to retrieve the object
@SessionAttribute
, but your code snippet doesn't contain it. Therefore, how did you use it? – sjngm Jul 18 '13 at 11:53@SessionAttributes("userObject")
i used this in my code – jackyesind Jul 18 '13 at 11:56