解决Spring的PageNotFound错误
来源:网络收集 点击: 时间:2024-05-302016-06-05 23:43:03,329 WARN - No mapping found for HTTP request with URI in DispatcherServlet with name SpringMVC

经过研究和分析,解决办法如下:
(1)查看项目的index页面是否能在浏览器正常打开

可以看到上面是可以打开的。
查看配置org.springframework.web.servlet.DispatcherServlet前端控制器在web.xml文件中的servlet-name是什么。
此处为SpringMVC

查看是否使用servlet-name-servlet.xml文件。此处没有使用
即使用contextConfigLocation变量中的文件classpath:config/spring-context.xml来加载Spring应用上下文

其它会刚才打开首页的链接已经暗示,这个webapp的名字不是servletname
因为打开的首页是这个webapp的index.jsp页面,不是tomcat默认的欢迎页


那就看看Controller中配置的内容吧
可以看到class上配置的路径是@RequestMapping(value = /pubsub)
@RequestMapping(value = /sub)public String Subscriber(Model model) {
即url:http://localhost:8080/pubsub/pub可以打开/WEB-INF/jsp/subResult.jsp页面

have a try!
与预期一致,页面可以正常打开,功能也正常



这个问题理顺后,看了看tomcat在deploy这个webapp里的日志,发现人家tomcat其实什么都给说了
2016-06-05 23:42:22,923 INFO - JSR-250 javax.annotation.ManagedBean found and supported for component scanning
2016-06-05 23:42:23,035 INFO - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1f55cb3: defining beans ; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@1353e78
2016-06-05 23:42:23,157 INFO - Mapped URL path onto handler pubSubController
2016-06-05 23:42:23,157 INFO - Mapped URL path onto handler pubSubController
2016-06-05 23:42:23,157 INFO - Mapped URL path onto handler pubSubController
2016-06-05 23:42:23,157 INFO - Mapped URL path onto handler pubSubController
2016-06-05 23:42:23,157 INFO - Mapped URL path onto handler pubSubController
2016-06-05 23:42:23,157 INFO - Mapped URL path onto handler pubSubController

版权声明:
1、本文系转载,版权归原作者所有,旨在传递信息,不代表看本站的观点和立场。
2、本站仅提供信息发布平台,不承担相关法律责任。
3、若侵犯您的版权或隐私,请联系本站管理员删除。
4、文章链接:http://www.1haoku.cn/art_862091.html