Two Laptop Bag*
The moose likes Other Application Frameworks and the fly likes Spring ModelAndView Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Spring ModelAndView Question" Watch "Spring ModelAndView Question" New topic
Author

Spring ModelAndView Question

Jon Jensen
Greenhorn

Joined: Oct 31, 2008
Posts: 6
I created my first spring controller without many problems and everything works as I expect except for one item. When I call:



I expect that the URL in my browser would change from login.html to home. The page displays just fine, its just the URL that doesn't change. Does it only change when you use another urlMapping?

Thanks.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Well the "view" you return is just a string, it isn't a URL. The String is used by a ViewResolver, to resolve that String to a real view, which might or might not be an html, htm, jsp, Servlet, or any other view technology. So "home" is not necessarily even going to be in the URL.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

The URL of the new page doesn't show up in the browser because the new page is being sent as the response of the first page's request. The solution to this problem is usually known under the term "redirect after post".

You'll either need to explicitly use a RedirectView or in the controller's bean definition, prepend the successView property with "redirect:". I also think you'll have to use the actual URL and not just a mapping name here.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Jon Jensen
Greenhorn

Joined: Oct 31, 2008
Posts: 6
Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Spring ModelAndView Question
 
Similar Threads
Unable to incluse a css file in spring
session.invalidate()called after return new ModelAndVie(..)create new session?
controller don't display view
Spring MVC question
Page appears only on refresh