1

Here is my XML configuration:

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"

     ...

    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd

        ... ">

    <resources mapping="/resources/**" location="/resources/" />
    <resources mapping="/style/**" location="/resources/style/" />
    <resources mapping="/script/**" location="/resources/script/" />
    <resources mapping="/images/**" location="/resources/images/" />
    <resources mapping="/uploaded/**" location="/resources/uploaded/" />

    <interceptors>
        <interceptor>
            <mapping path="/**" />

            <exclude-mapping path="/style/**" />
            <exclude-mapping path="/script/**" />
            <exclude-mapping path="/images/**" />
            <exclude-mapping path="/uploaded/**" />
            <exclude-mapping path="/resources/**" />

            <beans:bean class="com.example.MyInterceptor" />
        </interceptor>
    </interceptors>

</beans:beans>

My issue is when I browse a file in /style or other path in exclude mappins, such as /style/style.css, the interceptor code still run. Even if I change the config to <exclude-mapping path="/style/*" />, the issue still happen.

How do I set the config file to let <exclude-mapping> work?

Shiyou
  • 121
  • 1
  • 4
  • 16

1 Answers1

0

I found the solution.

As what gamerkore said in About mvc:intercepter,how to set excluded path said, spring add this feature in version 3.2 (my project had used ver. 3.1.1.RELEASE). It can work after updating the version of spring (I updated it to ver. 4.2.0.RELEASE)

Community
  • 1
  • 1
Shiyou
  • 121
  • 1
  • 4
  • 16
  • 2
    So how did you get it working then with the multiple exclude paths? It would be nice to see your code posted in the solution. I have multiple paths to exclude but it is not working for me. – Encryption Dec 08 '16 at 20:20