My dispatcher.xml sets resource chain like below:
<mvc:resources location="/static/" mapping="/static/**" cache-period="31536000">
<mvc:resource-chain resource-cache="true">
<mvc:resolvers>
<!--<bean class="org.springframework.web.servlet.resource.GzipResourceResolver"/>-->
<bean class="org.springframework.web.servlet.resource.CachingResourceResolver">
<constructor-arg ref="staticResourceCache"/>
</bean>
<bean class="org.springframework.web.servlet.resource.VersionResourceResolver">
<property name="strategyMap">
<map>
<entry key="/**">
<bean class="org.springframework.web.servlet.resource.ContentVersionStrategy"/>
</entry>
</map>
</property>
</bean>
<bean class="org.springframework.web.servlet.resource.PathResourceResolver"/>
</mvc:resolvers>
<mvc:transformers>
<bean class="org.springframework.web.servlet.resource.CachingResourceTransformer">
<constructor-arg ref="staticResourceCache"/>
</bean>
<bean class="org.springframework.web.servlet.resource.CssLinkResourceTransformer">
<!--<property name="allowedLocations" value="/static"> </property>-->
</bean>
</mvc:transformers>
</mvc:resource-chain>
</mvc:resources>
when I debug the codes ,I find that the resource chains has two PathResourceResolver, why ?Thank you! ResourceHttpRequestHanndler state
I suspect Spring is adding a default
PathResourceResolverbean with the default idpathResourceResolver. You are explicitly declaring one but without an id, so you are ending up with 2.The Spring Framework does this a lot - ie. it will create default beans for you unless you specify a bean with the same id.
You can test this theory by:
1) comment your
PathResourceResolverout of your config? Do you end up with 1?2) use your
PathResourceResolverin your config, but give it the idpathResourceResolver? Do you end up with 1?