Announcement Announcement Module
Collapse
No announcement yet.
URL not changing when returning a ModelAndView instance from inside my controller Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • URL not changing when returning a ModelAndView instance from inside my controller

    Hello All!

    For a new project, I'm using Spring MVC.

    I have a login page, a loginController class (inheriting SimpleFormController).
    When returning a ModelView instance in one of my controller methods, I set the view name to "index".
    So, logically, I'm expecting Spring MVC to display the index.jsp page, what it does.
    However, it does not change the url, so SiteMesh cannot map the new url to the required decorator. It still uses the current
    decorator, which is the wrong one (and thus, the page layout is totally wrong).

    However, when redirecting to another page using a ParameterizableViewController, it's working (but I cannot use this solution because I have to handle form data).

    Any idea why the url is not changing ?

    Thanks to everybody !

    Stéphane

  • #2
    Try using the following line of code in your onSubmit method in loginController which extends SimpleFormController.
    ModelAndView mv = new ModelAndView(new RedirectView("newPage.htm"));
    This should change the url to the desired page and will also pass the model data to the redirected page.
    Reply me if you need further clarifications.
    cheers,
    Sushant

    Comment


    • #3
      Thanks, it's working !


      Stéphane

      Comment


      • #4
        thanks it's working this code is useful for me

        Comment

        Working...
        X