Announcement Announcement Module
Collapse
No announcement yet.
How to apply an existing interceptor to an annotation controller? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to apply an existing interceptor to an annotation controller?

    I already have an interceptor from a pre-2.5 Spring application. Now, I have an annotation controller which shall be applied for the same interceptor for a business logic validation. Is it doable?

  • #2
    Just like you do it with the other interceptors. Configure the appropriate HandlerMapping and inject the interceptors into it.

    Comment


    • #3
      Originally posted by Marten Deinum View Post
      Just like you do it with the other interceptors. Configure the appropriate HandlerMapping and inject the interceptors into it.
      Thanks for the information. I, however, am not sure how it works out. The pre-2.5 way is the followings:
      Code:
      	<bean id="editBusinessEntryHandlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
      		<property name="interceptors">
      			<list>
      				<ref bean="businessOwnerInterceptor"/>
      			</list>
      		</property>
      		<property name="urlMap">
      			<map>
      				<entry key="/directory/editEntry.htm"><ref local="editingEntryFormController"/></entry>	
      			</map>
      		</property>
      	</bean>
      For the annotation controller, I can replace the SimpleUrlHandlerMapping with DefaultAnnotationHandlerMapping. I, however, can't find how to map it with the controller. The interceptor shall not be applied to all annotation controllers, but that one. I can't see any document in the regard including the Spring API document (/spring-framework-2.5.6/docs/api/index.html). The API document mentions about the "interceptors" property, but nothing else. Or, I shall use a customized build like this one: http://www.scottmurphy.info/spring_f...r_interceptors
      Last edited by vw729; May 30th, 2009, 08:03 PM.

      Comment

      Working...
      X