is default handler mapping is overridden when we c

2019-06-13 17:28发布

I want to know is default handler mapping created by spring mvc framework override if we create our custom handler mapping. I have doubt because i created custom handler mapping in two projects in one

  1. BeanNameHandlerMapping
  2. SimpleUrlHandlerMapping is injected in dispatcher servlet but in another one these are not registered in dispatcher servlet

I am using different version of spring 3 framework for these two project. Is it because of version change in spring 3

I am not getting default handler mapping in spring 3.0 but getting in spring 3 higher version

Thanks

1条回答
Animai°情兽
2楼-- · 2019-06-13 17:56

Specify the order of your custom HandlerMapping to have the lowest int value so that it gets tried first over the other registered HandlerMappings.

Explanation

Figuring out the available HandlerMappings in the web context is part of the DispatcherServlet initialisation:

enter image description here

That method, is discovering all the registered HandlerMappings and as you can see it is sorting them based on their defined order.

enter image description here

Otherwise it is falling back on the default handlerMapping: the BeanNameUrlHandlerMapping

查看更多
登录 后发表回答