开发者

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">
            开发者_Go百科    <ref bean="sessionFactory" />
            </property>
        </bean>

My question, how to configure excluded path?


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜