【发布时间】:2013-07-12 07:36:35
【问题描述】:
文档说:
提供静态内容的资源位置,在 Spring 资源模式中指定。每个位置都必须指向一个有效的目录。可以将多个位置指定为逗号分隔的列表,并且将按照指定的顺序检查给定资源的位置。例如,“/, classpath:/META-INF/public-web-resources/”的值将允许从 Web 应用根目录和包含 /META-INF/ 的类路径上的任何 JAR 提供资源public-web-resources/ 目录,Web 应用根目录中的资源优先。
我将资源放置在我的应用程序之外,如下所示:
- 常见
- CSS
- js
- 模块1
- CSS
- js
- 模块2
- ...
我希望在localhost/%module_name%/resources/ 上提供模块特定资源,在localhost/%module_name%/resources/common/ 上提供公共资源
在 web-context.xml 对于 module1 我有:
<mvc:resources mapping="/resources/**" location="${spring.view.resourcesDir}/"/>
当我设置spring.view.resourcesDir=file:///c://resources//module1 请求时
localhost/module1/resources/css 工作正常。
但是当我设置时
spring.view.resourcesDir=file:///c://resources//module1,file:///c://resources//
一切都会中断,localhost/module1/resources/css 和 localhost/module1/resources/common/css 都会返回 404 错误。
如果位置没有嵌套,也会发生同样的事情,即使第二个位置完全不同,例如 file:///d://
谁能帮我解决这个问题?
【问题讨论】:
标签: xml spring-mvc