Announcement Announcement Module
No announcement yet.
interceptor on a single handler mapping Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • interceptor on a single handler mapping


    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.


  • #2
    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.


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


        • #5
          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?
          <beans xmlns="" 
          	<mvc:annotation-driven  />


          • #6
            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.