Search code examples
javaspringmappinginterceptorrequest-mapping

How to map Spring Interceptor


I'm trying to map a Spring Interceptor so it catches every '*.do' request, but I can only make it work in a 'single level'.

My Interceptor mapping path is "/*.do", and I can only intercept URIs like /app/action.do

If I request /app/anotherLevel/action.do the Interceptor is not triggered.

I've noticed that mapping path = "/*/*.do" catches 'second level' requests, but that does not look correct.

What should be the value of interceptor mapping path so I can intercept all *.do request regardless of the level?

Thanks a lot and sorry for any english mistakes.


Solution

  • I finally figured out how to map every level.

    There was a slash missing, so the correct value should be /**/*.do.

    I found the trick in the link below:
    http://docs.spring.io/spring/docs/current/spring-framework-reference/html/mvc.html#mvc-localeresolver-interceptor

    Thanks a lot!