I've got a weird problem I haven't been able to figure out.
Using the following viewResolver configuration renders a pretty Velocity template:
For example, new ModelAndView("foo") renders the template from /WEB-INF/velocity/foo.vm.Code:<bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer"> <property name="resourceLoaderPath" value="/WEB-INF/velocity/"/> </bean> <bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver"> <property name="cache" value="true"/> <property name="prefix" value=""/> <property name="suffix" value=".vm"/> </bean>
However, when I tried to create a similar configuration for rendering JSP's (and commented out the Velocity stuff), I'm getting a HTTP 200 with no content at all.
Trying to access the URL http://localhost:8080/myapp/foo.html (I've mapped the DispatcherServlet to "*.html") results in the following log output:Code:<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass"><value>org.springframework.web.servlet.view.JstlView</value></property> <property name="prefix"><value>/WEB-INF/jsp/</value></property> <property name="suffix"><value>.jsp</value></property> </bean>
What wonders me is that the log clearly claims the request was forwarded to "/WEB-INF/jsp/list.jsp" but the JSP is never rendered. Instead, as I mentioned already, I get 0 bytes of content and a HTTP 200 response code.Code:[org.springframework.web.servlet.DispatcherServlet] - <Testing handler map [org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping@5a67c9] in DispatcherServlet with name 'app'> [org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping] - <Looking up handler for [/list.html]> [org.springframework.web.servlet.DispatcherServlet] - <Testing handler adapter [org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter@153c375]> [org.springframework.web.servlet.DispatcherServlet] - <Last-Modified value for [/myapp/list.html] is [-1]> [org.springframework.web.servlet.DispatcherServlet] - <DispatcherServlet with name 'app' received request for [/myapp/list.html]> [org.springframework.web.servlet.DispatcherServlet] - <Testing handler adapter [org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter@153c375]> [org.springframework.web.servlet.view.InternalResourceViewResolver] - <Cached view 'list'> [org.springframework.web.servlet.DispatcherServlet] - <Rendering view [org.springframework.web.servlet.view.JstlView: name 'list'; URL [/WEB-INF/jsp/list.jsp]] in DispatcherServlet with name 'app'> [org.springframework.web.servlet.view.JstlView] - <Rendering view with name 'list' with model {list=[First, Second, Third]} and static attributes {}> [org.springframework.web.servlet.view.JstlView] - <Added model object 'list' of type [java.util.ArrayList] to request in InternalResourceView 'list'> [org.springframework.web.servlet.view.JstlView] - <Forwarded to resource [/WEB-INF/jsp/list.jsp] in InternalResourceView 'list'> [org.springframework.web.servlet.DispatcherServlet] - <Successfully completed request> [org.springframework.web.context.support.XmlWebApplicationContext] - <Publishing event in context [WebApplicationContext for namespace 'app-servlet']: RequestHandledEvent: url=[/myapp/list.html]; time=[871ms]; client=[127.0.0.1]; method=[GET]; servlet=[app]; session=[null]; user=[null]; status=[OK]> [org.springframework.web.context.support.XmlWebApplicationContext] - <Publishing event in context [Root WebApplicationContext]: RequestHandledEvent: url=[/myapp/list.html]; time=[871ms]; client=[127.0.0.1]; method=[GET]; servlet=[app]; session=[null]; user=[null]; status=[OK]>
Here's the web.xml stuff that maps the request to the controller:
Any help is obviously appreciated. Especially if it makes me slap my forehead ;-)Code:<servlet> <servlet-name>app</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>2</load-on-startup> </servlet> <servlet-mapping> <servlet-name>app</servlet-name> <url-pattern>*.html</url-pattern> </servlet-mapping>


Reply With Quote