tintin
tintin

Reputation: 5867

Is it possible to configure handler interceptors without giving controller name

I want an interceptor to be called for all the url's with pattern /user/display/* and don't want to configure the controller name to which these url's map to.

Spring documentation gives the following example

<bean id="handlerMapping"
          class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
        <property name="interceptors">
            <list>
                <ref bean="officeHoursInterceptor"/>
            </list>
        </property>
        <property name="mappings">
            <value>
                 /user/display/*=editAccountFormController
            </value>
        </property>
    </bean>

In my case i don't want to give editAccountFormController. Is it possible to do that?

Upvotes: 1

Views: 864

Answers (1)

skaffman
skaffman

Reputation: 403501

You can specify interceptors independently of the controllers using <mvc:interceptors>, e.g.

<mvc:interceptors>
    <mvc:interceptor>
        <mapping path="/user/display/*"/>
        <bean class="com.x.y.MyInterceptor" />
    </mvc:interceptor>
</mvc:interceptors>

See docs for more detail.

Upvotes: 4

Related Questions