Update resource handler XML Namespace
This change introduces a new <mvc:resource-chain/> tag that mirrors
the ResourceChainRegistration java config counterpart.
Resolvers and Transformers can be registered with bean/ref tags, and
specific tags have been created for <mvc:version-resovlver> and
<mvc:resource-cache> in order to make common configurations easier.
Note that a specific "auto-configuration" attribute on the
resource-chain allows to completely disable default registration of
Resolvers and Transformers (sane defaults considered by the Framework).
<mvc:resources mapping="/resources/**" location="/, classpath:/META-INF/">
<mvc:resource-chain>
<mvc:resource-cache cache="resourceCache"/>
<mvc:resolvers>
<mvc:version-resolver>
<mvc:fixed-version-strategy version="abc" patterns="/**/*.js"/>
<mvc:content-version-strategy patterns="/**"/>
</mvc:version-resolver>
</mvc:resolvers>
<mvc:transformers>
<bean class="org.springframework.web.servlet.resource.AppCacheManifestTransformer"/>
</mvc:transformers>
</mvc:resource-chain>
</mvc:resources>
This also fixes a typo in the class name of
AppCacheManifestResourceTransfo*r*mer.
Issue: SPR-12129
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
|
||||
|
||||
<mvc:resources mapping="/resources/**" location="/, classpath:/META-INF/">
|
||||
<mvc:resource-chain auto-registration="false">
|
||||
<mvc:resolvers>
|
||||
<mvc:version-resolver>
|
||||
<mvc:fixed-version-strategy version="abc" patterns="/**/*.js"/>
|
||||
<mvc:version-strategy patterns="/**">
|
||||
<bean class="org.springframework.web.servlet.resource.ContentVersionStrategy" />
|
||||
</mvc:version-strategy>
|
||||
</mvc:version-resolver>
|
||||
<ref bean="gzipResourceResolver"/>
|
||||
<bean class="org.springframework.web.servlet.resource.PathResourceResolver"/>
|
||||
</mvc:resolvers>
|
||||
<mvc:transformers>
|
||||
<bean class="org.springframework.web.servlet.resource.CachingResourceTransformer">
|
||||
<constructor-arg name="cache" ref="resourceCache" />
|
||||
</bean>
|
||||
<bean class="org.springframework.web.servlet.resource.AppCacheManifestTransformer"/>
|
||||
</mvc:transformers>
|
||||
</mvc:resource-chain>
|
||||
</mvc:resources>
|
||||
|
||||
<bean id="gzipResourceResolver" class="org.springframework.web.servlet.resource.GzipResourceResolver" />
|
||||
<bean id="resourceCache" class="org.springframework.cache.concurrent.ConcurrentMapCache">
|
||||
<constructor-arg name="name" value="resourceCache"/>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright 2002-2014 the original author or authors.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
|
||||
|
||||
<mvc:resources mapping="/resources/**" location="/, classpath:/META-INF/">
|
||||
<mvc:resource-chain>
|
||||
<mvc:resource-cache cache="resourceCache"/>
|
||||
<mvc:resolvers>
|
||||
<mvc:version-resolver>
|
||||
<mvc:fixed-version-strategy version="abc" patterns="/**/*.js"/>
|
||||
<mvc:content-version-strategy patterns="/**"/>
|
||||
</mvc:version-resolver>
|
||||
</mvc:resolvers>
|
||||
<mvc:transformers>
|
||||
<bean class="org.springframework.web.servlet.resource.AppCacheManifestTransformer"/>
|
||||
</mvc:transformers>
|
||||
</mvc:resource-chain>
|
||||
</mvc:resources>
|
||||
|
||||
<bean id="resourceCache" class="org.springframework.web.servlet.config.MvcNamespaceTests$TestResourceCache">
|
||||
<constructor-arg name="name" value="resourceCache"/>
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
|
||||
|
||||
<mvc:resources mapping="/resources/**" location="/, classpath:/META-INF/">
|
||||
<mvc:resolvers>
|
||||
<bean class="org.springframework.web.servlet.resource.PathResourceResolver"/>
|
||||
<ref bean="gzipResourceResolver" />
|
||||
</mvc:resolvers>
|
||||
<mvc:transformers>
|
||||
<ref bean="cachingResourceTransformer" />
|
||||
<bean class="org.springframework.web.servlet.resource.CssLinkResourceTransformer" />
|
||||
</mvc:transformers>
|
||||
</mvc:resources>
|
||||
|
||||
<bean id="gzipResourceResolver" class="org.springframework.web.servlet.resource.GzipResourceResolver" />
|
||||
<bean id="resourceCache" class="org.springframework.cache.concurrent.ConcurrentMapCache">
|
||||
<constructor-arg name="name" value="resourceCache"/>
|
||||
</bean>
|
||||
<bean id="cachingResourceTransformer" class="org.springframework.web.servlet.resource.CachingResourceTransformer">
|
||||
<constructor-arg name="cache" ref="resourceCache" />
|
||||
</bean>
|
||||
</beans>
|
||||
Reference in New Issue
Block a user