PDA

View Full Version : pass some parameters to success view


shoa
Jun 7th, 2006, 07:45 AM
Hello

I have a successView that is a simpleFormController. From the formView (also simpleFormController), I want to pass some parameters in onSubmit() function. Based on different parameters, the success view will show different items in the page. How I can do that. I only know somthing like

ModelAndView mv = new ModelAndView(new RedirectView(getSuccessView()));
return mv;

I donot want to put anything in session

Thanks for any help
sho

betabagel
Jun 7th, 2006, 07:50 AM
You can pass a parameter, eg an id, like this:

return new ModelAndView(new RedirectView(getSuccessView()), "id",
encryptedID);

Mark Fisher
Jun 7th, 2006, 07:59 AM
and for multiple parameters, you can simply pass the viewName and the model (which should be a Map), such as:

Map model...
// add to model
return new ModelAndView(view, model);

or...

ModelAndView mav = new ModelAndView(view);
mav.addObject("x", x);
mav.addObject("y", y);
return mav;

Have a look at the Step-by-Step MVC tutorial: http://www.springframework.org/docs/MVC-step-by-step/Spring-MVC-step-by-step.html

and also the reference doc: http://static.springframework.org/spring/docs/1.2.x/reference/mvc.html#mvc-controller