Spring-JS无法定位web资源



我正在使用Spring JS 2.3.0和Spring 3.0.5,我相信我已经为资源(css和JS文件)正确配置了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.js404未找到- http://localhost:8080/springmvc/resources/Spring-Dojo.js

有没有人能告诉我我做错了什么?

在这种情况下,您必须使用web.xml。

http://static.springsource.org/spring-webflow/docs/2.0.x/reference/html/ch11s02.html

如果你一直在使用spring security,那么你必须定义拦截url,像这样:<security:intercept-url pattern="/resources/**" filters="none" />

最新更新