Hailei Zhang
Hailei Zhang

Reputation: 63

About mvc:intercepter,how to set excluded path

As we know, we can config an interceptor like that:

 <mvc:interceptor>
        <mvc:mapping path="/outfit/**" />
        <bean class="OpenSessionInViewInterceptor">
            <property name="sessionFactory">
                <ref bean="sessionFactory" />
            </property>
        </bean>

My question, how to configure excluded path?

Upvotes: 5

Views: 14194

Answers (2)

gamerkore
gamerkore

Reputation: 1115

Since Spring 3.2 they added that feature.

See this example from the Spring documentation:

<mvc:interceptors>
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" />
<mvc:interceptor>
    <mapping path="/**"/>
    <exclude-mapping path="/admin/**"/>
    <bean class="org.springframework.web.servlet.theme.ThemeChangeInterceptor" />
</mvc:interceptor>
<mvc:interceptor>
    <mapping path="/secure/*"/>
    <bean class="org.example.SecurityInterceptor" />
</mvc:interceptor>

Here's the link to the doc

Upvotes: 10

Bozho
Bozho

Reputation: 597124

I don't think you can declaratively. But within the interceptor you can add an if(..) and verify whether the request uri should be excluded. You can set the exclusion paths as a list property in the interceptor xml definition.

For that you will have to extend the OSIV interceptor and add that custom logic & exclusion list property.

Upvotes: 0

Related Questions