Announcement Announcement Module
Collapse
No announcement yet.
Using different handler interceptors for different mappings Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using different handler interceptors for different mappings

    Hello, it might be a very simple newbie question, but I have the following problem. I want to use some handler interceptors, but not to all url mappings. So, I want to have a particular interceptor for one URL-pattern and another interceptor for another URL pattern. In the Spring documentation I found only an example, where the interceptor(s) are used to all mappings possible:
    Code:
        <bean id="handlerMapping" 
              class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">            
            <property name="interceptors">
                <list>
                    <ref bean="officeHoursInterceptor"/>
                </list>
            </property>
            <property name="mappings">
                <props>
                    <prop key="/*.form">editAccountFormController</prop>
                    <prop key="/*.view">editAccountFormController</prop>
                </props>
            </property>
        </bean>
    What should I do, when I want for example a 'interceptorOne' to be used only for URL patterns of type "/*.form" and a 'interceptorTwo' for "/*.view"?

  • #2
    simply define a new handler mapping bean with the interceptor you want. The dispatcher will check all beans of type HandlerMapping when a request comes in.

    Regards,

    Comment

    Working...
    X