Spring启动,解决已经解析的视图

时间:2014-07-22 11:08:00

标签: jsp spring-boot

我试图让基本的spring-boot jsp示例正常工作。

问题是我一直收到404错误。 在日志中,我可以看到正在调用控制器并返回正确的jsp视图。

但是DispatcherServlet正在尝试为jsp找到一个控制器。

日志:

2014-07-22 13:00:18.262 DEBUG 4716 --- [nio-9090-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /
2014-07-22 13:00:18.264 DEBUG 4716 --- [nio-9090-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Returning handler method [public java.lang.String sample.jsp.WelcomeController.welcome(java.util.Map<java.lang.String, java.lang.Object>)]
2014-07-22 13:00:18.265 DEBUG 4716 --- [nio-9090-exec-1] o.s.web.servlet.DispatcherServlet        : Last-Modified value for [/] is: -1
2014-07-22 13:00:18.279 DEBUG 4716 --- [nio-9090-exec-1] o.s.web.servlet.DispatcherServlet        : Rendering view [org.springframework.web.servlet.view.JstlView: name 'welcome'; URL [welcome]] in DispatcherServlet with name 'dispatcherServlet'
2014-07-22 13:00:18.279 DEBUG 4716 --- [nio-9090-exec-1] o.s.web.servlet.view.JstlView            : Added model object 'time' of type [java.util.Date] to request in view with name 'welcome'
2014-07-22 13:00:18.279 DEBUG 4716 --- [nio-9090-exec-1] o.s.web.servlet.view.JstlView            : Added model object 'message' of type [java.lang.String] to request in view with name 'welcome'
2014-07-22 13:00:18.282 DEBUG 4716 --- [nio-9090-exec-1] o.s.web.servlet.view.JstlView            : Forwarding to resource [welcome] in InternalResourceView 'welcome'
2014-07-22 13:00:18.285 DEBUG 4716 --- [nio-9090-exec-1] o.s.web.servlet.DispatcherServlet        : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/welcome]
2014-07-22 13:00:18.286 DEBUG 4716 --- [nio-9090-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /welcome
2014-07-22 13:00:18.288 DEBUG 4716 --- [nio-9090-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Did not find handler method for [/welcome]
2014-07-22 13:00:18.289  WARN 4716 --- [nio-9090-exec-1] o.s.web.servlet.PageNotFound             : No mapping found for HTTP request with URI [/welcome] in DispatcherServlet with name 'dispatcherServlet'
2014-07-22 13:00:18.289 DEBUG 4716 --- [nio-9090-exec-1] o.s.web.servlet.DispatcherServlet        : Successfully completed request
2014-07-22 13:00:18.289 DEBUG 4716 --- [nio-9090-exec-1] o.s.web.servlet.DispatcherServlet        : Successfully completed request

使用的代码是spring-boot示例中的示例代码:

https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-web-jsp

1 个答案:

答案 0 :(得分:1)

a bug in Spring 4.1 snapshots引起的问题是Boot的主分支使用的问题。在修复该错误之前,您应该使用该示例的早期版本,例如latest release (1.1.4)