请帮我弄清楚这种奇怪的行为,我在这里有一个基于Spring的项目https://github.com/riuvshin/spring-mvc-learn我想把*.war部署到tomcat 7.0。当我根据日志部署war来清理tomcat时,它应该可以正常工作,但当我尝试打开localhost:8080/contacts时,我得到了404错误。。。
如果我从IDE(intellij)启动该应用程序,它运行良好,如果有人能解释我错过了什么,我会非常高兴。
catalina.out
日志清楚地显示您的@Controller
映射到路径/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)
然而,您正试图使用路径访问此处理程序
localhost:8080/contacts
只有当你的网络应用程序被配置为具有/
的上下文路径时,这才会起作用,我很确定它不是。
尝试使用
localhost:8080/[myapp]/contacts
其中[myapp]
是应用程序在webapps
文件夹中的文件夹的名称。
请参阅以下关于如何更改路径的答案。