Please tell me whether it is possible to use both SimpleUrlHandlerMapping and AnnotationMapping in spring mvc.
Thank you.
Please tell me whether it is possible to use both SimpleUrlHandlerMapping and AnnotationMapping in spring mvc.
Thank you.
Yes, you can have as many as you like. Each will be consulted until one of them says "yes, I have a mapping for that request".
Declare each of them in your beans file like any other bean, they'll be consulted in the order in which they appear.
However, by default, DispatcherServlet
registers three different HandlerMapping
beans automatically, HttpRequestHandlerAdapter
, SimpleControllerHandlerAdapter
, and AnnotationMethodHandlerAdapter
, so it's possible you don't need to do this yourself - you can mix-and-match handlers from all three styles, and Spring will handle it out of the box.