Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Not able to run basic spring mvc example? -- Resource not found

 
Karnati Sudhakar
Ranch Hand
Posts: 270
Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
web.xml



spitter-servlet.xml


homeController.java




I am giving the url as http://localhost:8080/SpringMvcExample/home.jsp

and the error is resource not found...In tomcat log i found that showHomePage is invoked..SOP from showHomePage is logged..

whats wrong here?

Please help me..

Thanks in advance..

P.S.: Same posted on stackexchange.com link
 
Prasad Krishnegowda
Ranch Hand
Posts: 665
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, there is no need for you to initialize spitter-servlet.xml using context-param in web.xml, spring libraries will do it for you..
Try, mapping *.htm requests to springs dispatcher servlet, instead of *.jsp..
 
Karnati Sudhakar
Ranch Hand
Posts: 270
Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prasad Krishnegowda wrote:First, there is no need for you to initialize spitter-servlet.xml using context-param in web.xml, spring libraries will do it for you..


Prasad thanks for your reply..

I commented the following code in web.xml


and i am getting the below error:

I think the above line is necessary as i don't have root level context..i just have dispatcher servlet context.

exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]

Prasad Krishnegowda wrote:Try, mapping *.htm requests to springs dispatcher servlet, instead of *.jsp..


Same error..

Any other suggestions guys..


EDITED: Prasad, I did not do it correctly, what you said is correct and it is working now..Thanks for reply
 
Karnati Sudhakar
Ranch Hand
Posts: 270
Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

This question has been resolved..Please follow this link for the answer link

The issue is for dispatcher servlet url mapping should not be *.jsp..

I don't know why?
 
Prasad Krishnegowda
Ranch Hand
Posts: 665
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Karnati Sudhakar wrote:Guys,


The issue is for dispatcher servlet url mapping should not be *.jsp..

I don't know why?


This is because, your view also is a JSP, so when the view is rendered it maps to some .jsp page, and the controller again will route it to spring dispatcher servlet... This results in JSP pages not been rendered..
Anyway, glad that it is working now..
 
Karnati Sudhakar
Ranch Hand
Posts: 270
Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prasad Krishnegowda wrote:
Karnati Sudhakar wrote:Guys,
The issue is for dispatcher servlet url mapping should not be *.jsp..
I don't know why?

This is because, your view also is a JSP, so when the view is rendered it maps to some .jsp page, and the controller again will route it to spring dispatcher servlet... This results in JSP pages not been rendered..
Anyway, glad that it is working now..


Thanks buddy..seems like these kind of concepts can be learn only through experience..

Thanks for your time.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic