使用SpringMVC将所有css资源映射到单个文件夹

时间:2011-05-06 15:05:06

标签: spring spring-mvc staticresource

有没有办法映射所有css资源,以便它们都是从SpringMVC的/ css文件夹中提供的? 防爆。 /login/sampleUser/ie.css映射到/css/ie.css

我一直在尝试使用<mvc:resources mapping="/css/**" location="/css/" >,但似乎没有用。

由于

1 个答案:

答案 0 :(得分:2)

您可以使用Tuckey Url Rewrite Filter。在那里,您可以定义更复杂的重写规则。

 <!-- I do not know if this fiter works (correctly), but it should
      demonstrate how it works-->
 <rule>
    <!-- redirect everything that ends with .css
         to resources, with same file name -->
    <from>/(.*)/$.css</from>
    <to type="redirect">/resouces/$1</to>
 </rule>