Results 1 to 3 of 3

Thread: How to apply an existing interceptor to an annotation controller?

  1. #1

    Default 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?
    [URL="http://vicina.info"] 新闻,社区新闻,分类广告

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    Just like you do it with the other interceptors. Configure the appropriate HandlerMapping and inject the interceptors into it.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3

    Default

    Quote 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...inter ceptors
    Last edited by vw729; May 30th, 2009 at 08:03 PM.
    [URL="http://vicina.info"] 新闻,社区新闻,分类广告

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •