스프링 MVC에서 버그를 발견했다고 생각합니다. 웹 xml의 서블릿 경로가 작은 따옴표없이 '/'또는 '/ *'이면 JstlView가 작동하지 않습니다. 직접 시도하고 스프링 MVC를 기반으로 작동하는 웹 애플리케이션을 가져온 다음 '/'또는 '/ *'와 일치하도록 디스패처 서블릿 경로를 조정 한 다음 페이지를 방문 할 수 있습니다 (물론 새 올바른 URL 사용) 400 오류가 발생합니다.
다음은 내 예입니다. 스프링 mvc 앱이 있으며 이것은 웹 xml에 있습니다.
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/mvc/*</url-pattern>
</servlet-mapping>
배포 및 방문 :
http://localhost:8080/contextroot/mvc/template
페이지가 완벽하게 표시됩니다. 다음은 로그입니다.
21:24:05.024 [http-bio-8080-exec-92] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Looking up handler method for path /template
21:24:05.048 [http-bio-8080-exec-92] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Returning handler method [public java.lang.String com.project.www.controller.ResultController.getPersonList(org.springframework.ui.ModelMap)]
21:24:05.050 [http-bio-8080-exec-92] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'resultController'
21:24:05.056 [http-bio-8080-exec-92] DEBUG o.s.web.servlet.DispatcherServlet - Last-Modified value for [/contextroot/mvc/template] is: -1
21:24:05.104 [http-bio-8080-exec-92] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Invoking afterPropertiesSet() on bean with name 'template'
21:24:05.106 [http-bio-8080-exec-92] DEBUG o.s.web.servlet.DispatcherServlet - Rendering view [org.springframework.web.servlet.view.JstlView: name 'template'; URL [/WEB-INF/jsp/template.jsp]] in DispatcherServlet with name 'dispatcher'
21:24:05.124 [http-bio-8080-exec-92] DEBUG o.s.web.servlet.view.JstlView - Forwarding to resource [/WEB-INF/jsp/template.jsp] in InternalResourceView 'template'
21:24:05.695 [http-bio-8080-exec-92] DEBUG o.s.web.servlet.DispatcherServlet - Successfully completed request
그래서 그것은 모두이 줄 위에서 작동하지만 이제 웹 xml을 다음과 같이 변경합니다.
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
재배치 및 방문 :
http://localhost:8080/contextroot/template
하지만 400 오류가 발생합니다. 다음은 로그입니다.
21:09:11.365 [http-bio-8080-exec-78] DEBUG o.s.web.servlet.DispatcherServlet - DispatcherServlet with name 'dispatcher' processing GET request for [/contextroot/template]
21:09:11.372 [http-bio-8080-exec-78] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Looking up handler method for path /template
21:09:11.383 [http-bio-8080-exec-78] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Returning handler method [public java.lang.String com.AnnaUnivResults.www.controller.ResultController.getPersonList(org.springframework.ui.ModelMap)]
21:09:11.384 [http-bio-8080-exec-78] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'resultController'
21:09:11.387 [http-bio-8080-exec-78] DEBUG o.s.web.servlet.DispatcherServlet - Last-Modified value for [/contextroot/template] is: -1
21:09:11.437 [http-bio-8080-exec-78] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Invoking afterPropertiesSet() on bean with name 'template'
21:09:11.440 [http-bio-8080-exec-78] DEBUG o.s.web.servlet.DispatcherServlet - Rendering view [org.springframework.web.servlet.view.JstlView: name 'template'; URL [/WEB-INF/jsp/template.jsp]] in DispatcherServlet with name 'dispatcher'
21:09:11.455 [http-bio-8080-exec-78] DEBUG o.s.web.servlet.view.JstlView - Forwarding to resource [/WEB-INF/jsp/template.jsp] in InternalResourceView 'template'
21:09:11.456 [http-bio-8080-exec-78] DEBUG o.s.web.servlet.DispatcherServlet - DispatcherServlet with name 'dispatcher' processing GET request for [/contextroot/WEB-INF/jsp/template.jsp]
21:09:11.457 [http-bio-8080-exec-78] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Looking up handler method for path /WEB-INF/jsp/template.jsp
21:09:11.459 [http-bio-8080-exec-78] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Did not find handler method for [/WEB-INF/jsp/template.jsp]
21:09:11.460 [http-bio-8080-exec-78] WARN o.s.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/contextroot/WEB-INF/jsp/template.jsp] in DispatcherServlet with name 'dispatcher'
21:09:11.461 [http-bio-8080-exec-78] DEBUG o.s.web.servlet.DispatcherServlet - Successfully completed request
21:09:11.464 [http-bio-8080-exec-78] DEBUG o.s.web.servlet.DispatcherServlet - Successfully completed request
나는 이것이 봄의 버그라고 확신합니다. 나는 이것을 봄의 사이트에 게시하고 싶었지만 분명히 봄 질문 페이지는 당신이 내게 묻는다면 일종의 속임수 인 StackOverflow로 당신을 보냅니다.
내 질문은 이것이 버그입니까?
로 변경 /
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<!--url-pattern>/*</url-pattern-->
<url-pattern>/</url-pattern>
</servlet-mapping>
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다