Spring MVC BeanNameUrlHandlerMapping example
2015-08-26 07:35
447 查看
In Spring MVC,
In above example, If URI pattern
Note
Additionally, this mapping is support Ant style regex pattern match.
Actually, declare
So, the above
BeanNameUrlHandlerMappingis the default handler mapping mechanism, which maps URL requests to the name of the beans. For example,
<beans ...> <bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/> <bean name="/welcome.htm" class="com.mkyong.common.controller.WelcomeController" /> <bean name="/streetName.htm" class="com.mkyong.common.controller.StreetNameController" /> <bean name="/process*.htm" class="com.mkyong.common.controller.ProcessController" /> </beans>
In above example, If URI pattern
/welcome.htmis requested,
DispatcherServletwill forward the request to the “
WelcomeController“.
/streetName.htmis requested,
DispatcherServletwill forward the request to the “
StreetNameController“.
/processCreditCard.htmor
/process{any thing}.htmis requested,
DispatcherServletwill forward the request to the “
ProcessController“.
Note
Additionally, this mapping is support Ant style regex pattern match.
Actually, declare
BeanNameUrlHandlerMappingis optional, by default, if Spring can’t found handler mapping, the
DispatcherServletwill creates a
BeanNameUrlHandlerMappingautomatically.
So, the above
web.xmlfile is equivalence to the following
web.xml:
<beans ...> <bean name="/welcome.htm" class="com.mkyong.common.controller.WelcomeController" /> <bean name="/streetName.htm" class="com.mkyong.common.controller.StreetNameController" /> <bean name="/process*.htm" class="com.mkyong.common.controller.ProcessController" /> </beans>
相关文章推荐
- 【LeetCode-面试算法经典-Java实现】【202-Happy Number(开心数字)】
- Android handleMessage 的简单用法案例
- 黑马程序员——ios基础---Objective-C:构造方法、@property、MRC
- Android Api Demos登顶之路(四十八)Menu
- Unity Game Programming AI(1)人工智能导论
- android sdk
- iOS @synthesize var = _var 变量前置下划线解释
- Objective-C之run loop详解
- Unity3D圣典学习【2】之CharacterController
- cocos2dx3.X shader使图片置灰
- Android 入门笔记--从零开始
- 【零基础学习iOS开发】【转载】
- 仿微信朋友圈双击顶部回到最前端(GestureDetector.OnDoubleTapListener)
- Android笔记(十九) Android中的Fragment
- Android 新浪微博api开发
- IOS响应式编程框架ReactiveCocoa(RAC)使用示例
- 开发中最常用的GitHub上 优秀的 Android 开源项目整理
- Android在同一个活动中加载两个布局,一个是XML还有个是draw(即自己用画布画的)
- iOS截取视频预览图,截图方向错误的解决
- iOS 类似简单的第三方微博客户端,可进行登录微博浏览相关信息