Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ModelAndView returning wrong JSP

 
Bruno Dovogja
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Bruno Dovogja
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have the dispatcher servlet mapped to / in the web.xml?
 
Bruno Dovogja
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I resolved the issue.
It was a wrong import in my controller.



Should be:



Thank you for your replies!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic