Question

please help me to figure out this strange behavior, I have a project based on Spring here https://github.com/riuvshin/spring-mvc-learn and I want deploy *.war to tomcat 7.0. When I deploy that war to clean tomcat according to logs it's should work every thing is ok, but when I try to open localhost:8080/contacts I've got 404 error...

If I launch that application from my IDE (intellij) it works fine, I will be super happy if any one can explain me what I missed.

Was it helpful?

Solution

The catalina.out log clearly shows that your @Controller is mapped to the path /contacts

INFO : org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[/contacts],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.apress.prospring3.ch17.web.controller.ContactController.list(org.springframework.ui.Model)

However you are trying to access this handler with the path

localhost:8080/contacts 

This will only work if you webapp is configured to have a context path of / and I'm pretty sure it isn't.

Try using

localhost:8080/[myapp]/contacts

where [myapp] is the name of your application's folder in the webapps folder.

See this answer on how to change that path.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top