Announcement Announcement Module
No announcement yet.
How do I pass a parameter to a successView? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How do I pass a parameter to a successView?

    I have a list page that takes a query string parameter (userListForm.htm?groupId=123). When someone clicks on a username in the list page, it will take them to a detail page (userEditForm.htm?userId=456). In my UserEditFormController (extends SimpleFormController) upon a successful submit/save I would like to display the userList.htm page so I have defined my successView as shown below:

    <bean id="userEditFormController " class=" ">
    <property name="commandName"><value>user</value></property>
    <property name="formView"><value>userEditform</value></property>
    <property name="successView"><value>userListForm</value></property>

    and here is my onSubmit method in the UserEditFormController:

    protected ModelAndView onSubmit(Object command) throws Exception {

    User user = (User)command;
    boolean result =;
    return new ModelAndView(getSuccessView());
    return new ModelAndView(getFormView());


    I need to pass the groupId to userListForm.htm which is my successView. How can I do this declaritively?

    I know I can do the following but I am looking for a better way.

    return new ModelAndView(new RedirectView("userListForm.htm?groupId=" + user.getGroupId()));

  • #2
    Re: How do I pass a parameter to a successView?

    When you do a redirect, the model is converted to query parameters. So you can do this...

    return new ModelAndView(new RedirectView("userListForm.htm"),"groupId", tGroupId());

    Or more declaritively, change your bean defintion to use "redirect:"

    <bean id="userEditFormController " class=" ">
    <property name="commandName"><value>user</value></property>
    <property name="formView"><value>userEditform</value></property>
    <property name="successView"><value>redirect:userListForm</value></property>

    Then you can use this...

    return new ModelAndView(getSuccessView(),"groupId",user.getGr oupId());