我正在使用SpringJS2.3.0和Spring3.0.5,我相信我已经为资源(css和JS文件)正确地配置了applicationContext.xml。以下是代码片段:
applicationContext.xml
<mvc:resources mapping="/resources/**" location="/, classpath:/META-INF/web-resources/" />
<mvc:default-servlet-handler />jsp页面
<LINK rel="stylesheet" type="text/css" href="<c:url value="/resources/js/xwt/themes/reboot2/reboot2.css"/>">
<LINK rel="stylesheet" type="text/css" href="<c:url value="/resources/js/xwt/themes/reboot2/reboot2-xwt.css"/>">
<SCRIPT type="text/javascript" src="<c:url value="/resources/js/dojo/dojo.js"/>"></SCRIPT>
<script type="text/javascript" src="<c:url value="/resources/Spring.js" />"> </script>
<script type="text/javascript" src="<c:url value="/resources/Spring-Dojo.js" />"> </script>web.xml
<servlet-mapping>
<servlet-name>Spring Servlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>当请求jsp页面时,不会访问Spring.js和Spring-Dojo.js,而会访问应用根目录下的其他资源。顺便说一句,spring-js在WEB-INF/lib文件夹下。Firebug展示了spring资源的404:
未找到404 -未找到http://localhost:8080/springmvc/resources/Spring.js 404 - http://localhost:8080/springmvc/resources/Spring-Dojo.js
如果我做错了什么,请给我指个方向好吗?
发布于 2012-01-24 00:22:18
在这种情况下,您必须使用web.xml。
http://static.springsource.org/spring-webflow/docs/2.0.x/reference/html/ch11s02.html
发布于 2012-12-19 00:37:20
如果您一直在使用spring security,那么您必须定义截取url,如下所示:<security:intercept-url pattern="/resources/**" filters="none" />
https://stackoverflow.com/questions/7847931
复制相似问题