在Spring MVC中创建自定义处理程序映射时,默认处理程序映射是否被覆盖? [英] is default handler mapping is overridden when we create custom handler mapping in spring mvc?

查看:74
本文介绍了在Spring MVC中创建自定义处理程序映射时,默认处理程序映射是否被覆盖?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我们创建自定义处理程序映射,我想知道是由Spring mvc框架覆盖的默认处理程序映射.我有疑问,因为我在一个项目中的两个项目中创建了自定义处理程序映射

  1. BeanNameHandlerMapping
  2. SimpleUrlHandlerMapping已注入调度程序servlet中,但另一种未在调度程序servlet中注册

我正在为这两个项目使用不同版本的spring 3框架.是因为春季3的版本更改了吗

我没有在Spring 3.0中获得默认的处理程序映射,而是在Spring 3更高版本中获得

谢谢

解决方案

指定 解决方案

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:

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

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

这篇关于在Spring MVC中创建自定义处理程序映射时,默认处理程序映射是否被覆盖?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆