
Originally Posted by
vasya10
The ModelAndView.addObject() simply adds the attributes to the request (--> request.setAttribute), while RedirectView does a sendRedirect internally, which means a new 'request' object.
Well you are right
. Totally read past the part of RedirectView.
However if you are using a redirect view I also assume (I know I know never assume
) you are redirecting to a page which also has a controller? You could pass the id of the user to this controller and retrieve the user in that controller putting it in the model (referenceData) and you should be good to go.
In your first controller
Code:
else if(inputPass.equals(realPass)){
User person=userMan.getInfoList(username);
Map model = errors.getModel();
model.put("person", person);
ModelAndView nModel= new ModelAndView(new RedirectView(getSuccessView()+"uname=person.getUserName()));
return nModel;
}
Then in the referenceData method of your next controller
Code:
protected Map referenceData(HttpServletRequest request) throws Exception {
String username = ServletRequestUtils.getStringParameter(request, "uname");
User person = userMan.getInfoList(username);
Map model = new HashMap();
model.put("person", person);
}
Of when you have put it into the session you could also change the referenceData to this instead of adding code to your jsp page.
Code:
protected Map referenceData(HttpServletRequest request) throws Exception {
User person = (User) WebUtils.getSessionAttribute(request, "person");
Map model = new HashMap();
model.put("person", person);
}