Spring MVC Tiles - Not picking up resource folder
I need to change mapping for my spring servlet to point to /sample vs. /sample.html.
I made a change in the url pattern to the following. The urlPattern is
<url-pattern>*.html</url-pattern>
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
Once this change is made, none of the style sheets reference in a folder are picking up. I thought this was because DispatcherServlet was trying to read this. When I try the following to my servlet-context.xml file, NOTHING works.
<bean id="viewResolver"
class="org.springframework.web.servlet.view.ResourceBundleViewResolver"
p:basename="views" />
<context:component-scan base-package="*****" />
<bean id="tilesC开发者_JS百科onfigurer"
class="org.springframework.web.servlet.view.tiles2.TilesConfigurer"
p:definitions="/WEB-INF/tiles-defs.xml" />
<mvc:resources mapping="/_res/**" location="/_res/"/>
I thought maybe I needed to add another view resolver, but that doesn't make any difference.
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
Any help would be greatly appreciated. It seems no matter what I do I get a 404 Error.
The resourses are accessed througt the spring dispatcher. So you need to make sure that the requests are delegated to the spring dispatcher sevlet in the web.xml.
You must delegate all requests to the dispatcher, not only html, but also css, images,...
精彩评论