This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Spring and the fly likes ModelAndView returning wrong JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "ModelAndView returning wrong JSP" Watch "ModelAndView returning wrong JSP" New topic
Author

ModelAndView returning wrong JSP

Bruno Dovogja
Greenhorn

Joined: Sep 06, 2012
Posts: 3
Hello,
I am new to this forum and trying to learn Spring.
I have a problem with a ModelAndView in my controller
and was wondering if anyone can help me out.

I hava a simple Administrator login page, when the administrator
logged in succesfully he comes to a page with a link directing to
a list of products. When he clicks te link I pass the list in a ModelAndView
with the JSP path it needs to call, but it seems to look for a different path.

Here is the admin page:


And here is the controller code


I also use a prefix and suffix in my controller xml file as you can see here:


So when I click the link on the administrator page I expect it to look for
"/ChocoWereld/WEB-INF/JSP/administrator/productlijst.jsp", instead i get:
"The requested resource (/ChocoWereld/WEB-INF/JSP/administrator/producten.jsp) is not available.".

I must be making some mistake but I can't figure it out. Help would be much appreciated.
Thanks!
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1632
    
    7

What you have should work. Try cleaning out the contents of your wptwebapps directory cleaning your workspace and republishing the code. Maybe something is not getting updated correctly on your application server. Also try setting a break point and starting in debug mode. Do you have another handler method that could be getting the request and returning a view name of producten?


[How To Ask Questions][Read before you PM me]
Bruno Dovogja
Greenhorn

Joined: Sep 06, 2012
Posts: 3
First of all I thank you for your reply. I don't find a wptwebapps directory anywhere on my system. I tried to
re install my tomcat server but I keep having the same problem. The only handler methods I have so far
are the ones in my controller I posted above. When I try to google my particular problem it also seems
I am the only person having this, it's really weird.

Now suddenly without any change to the code the administrator login page stopped working too,
when i try to login it looks for the url: "http://localhost:8080/ChocoWereld/administrator/administrator".
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1632
    
    7

You have the dispatcher servlet mapped to / in the web.xml?
Bruno Dovogja
Greenhorn

Joined: Sep 06, 2012
Posts: 3
Hi, I resolved the issue.
It was a wrong import in my controller.



Should be:



Thank you for your replies!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ModelAndView returning wrong JSP
 
Similar Threads
After and before Advice Dosent Fire in spring
Spring MVC
Problem running app under Tomcat v7
spring security 3.1 login not working.
Spring MVC: Getting resource not available for one Request Mapping while its working for the others.