Results 1 to 6 of 6

Thread: interceptor on a single handler mapping

  1. #1
    Join Date
    Jan 2011
    Posts
    5

    Default interceptor on a single handler mapping

    Hi,

    I've got a web context with an <mvc:annotation-driven /> tag to setup RequestMappingHandlerMapping for simple annotated controllers and a org.springframework.webflow.mvc.servlet.FlowHandle rMapping for a web flow.
    I'm trying to setup an interceptor (OpenEntityManagerInViewInterceptor) to apply to my simple annotated controllers but not to my web flow.
    I've tried to use <mvc:interceptors ...> but that registers my interceptor on both mappings. How can I set it up only on my RequestMappingHandlerMapping?

    I know I can filter my interceptors on request path, but that's not what I want, I just want the interceptor to apply to one mapping and not the other.

    Thanks

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

    Default

    The only way to do that is to do manual configuration of the HandlerMapping and register the interceptors yourself, at least if url mapping isn't sufficient.
    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
    Join Date
    Jan 2011
    Posts
    5

    Default

    OK, so what is the exact translation of <mvc:annotation-driven />?
    In other words, if I remove <mvc:annotation-driven /> from my context, what beans should I define instead?

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

    Default

    That depends on what you use/configure. You need at least the RequestMappingHandlerMapping/-HandlerAdapter...
    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

  5. #5
    Join Date
    Jan 2011
    Posts
    5

    Default

    That depends???

    My question is what would I need to manually define to have an exact same context as this one without using the mvc:annotation-driven tag?
    Code:
    <beans xmlns="http://www.springframework.org/schema/beans" 
               xmlns:mvc="http://www.springframework.org/schema/mvc"	
    	   xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd 
               http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
    
    	<mvc:annotation-driven  />
    </beans>

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

    Default

    Yes it depends.. It depends how you have configured annotation-driven, do you use it to serve static instances, do you have/use JSR-303 validation, do you use JSON/XML etc. So yes it depends, it depends on your settings and available jars!

    If you want the exact thing take a look at the source code for AnnotationDrivenBeanDefinitionParser (in the org.springframework.web.servlet.config) to know what you need depeding on YOUR environment.

    And as already mentioned in the previous post at a minimum you need the RequestMappingHandlerMapping/-HandlerAdapter.
    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

Tags for this Thread

Posting Permissions

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