标签:
<servlet> <servlet-name>springMVC</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:springMVC.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>springMVC</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>
如上:web.xml中,设置为拦截所有/请求,导致引用的文件找不到
可用如下方法处理:
/resource/css/* 映射到 /resources/css/
作用范围:view下的所有页面,类型为jsp
<!-- 过滤静态资源 --> <mvc:resources mapping="/resource/css/**" location="/resources/css/" /> <mvc:resources mapping="/resource/image/**" location="/resource/image/" /> <mvc:resources mapping="/resource/js/**" location="/resource/js/" /> <mvc:default-servlet-handler /> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/view/" /> <property name="suffix" value=".jsp" /> </bean>
如上设置之后,控制器中需要改变连接地址
...view/other/recommendation.jsp 改为 /other/recommendation
标签:
原文地址:http://www.cnblogs.com/shabi-ef/p/4220990.html