Spring MVC BeanNameUrlHandlerMapping example
In Spring MVC, BeanNameUrlHandlerMapping
is 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.htm
is requested,DispatcherServlet
will forward the request to the “WelcomeController
“./streetName.htm
is requested,DispatcherServlet
will forward the request to the “StreetNameController
“./processCreditCard.htm
or/process{any thing}.htm
is requested,DispatcherServlet
will forward the request to the “ProcessController
“.
Actually, declare BeanNameUrlHandlerMapping
is optional, by default, if Spring can’t found handler mapping, the DispatcherServlet
will creates a BeanNameUrlHandlerMapping
automatically.
So, the above web.xml
file 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>
Spring MVC BeanNameUrlHandlerMapping example的更多相关文章
- Spring MVC的handlermapping之请求分发如何找到正确的Handler(BeanNameUrlHandlerMapping,SimpleUrlHandlerMapping)
本文讲的是Spring MVC如何找到正确的handler, 前面请求具体怎么进入到下面的方法,不再细说. 大概就是Spring mvc通过servlet拦截请求,实现doService方法,然后进入 ...
- spring mvc: 多动作控制器(Controller下面实现多个访问的方法)MultiActionController / BeanNameUrlHandlerMapping
spring mvc: 多动作控制器(Controller下面实现多个访问的方法) 比如我的控制器是UserController.java,下面有home, add, remove等多个方法 访问地址 ...
- Spring MVC入门
1.什么是SpringMvc Spring MVC属于SpringFrameWork的后续产品,已经融合在Spring Web Flow里面.Spring 框架提供了构建 Web 应用程序的全功能 M ...
- spring mvc DispatcherServlet详解之前传---FrameworkServlet
做项目时碰到Controller不能使用aop进行拦截,从网上搜索得知:使用spring mvc 启动了两个context:applicationContext 和WebapplicationCont ...
- spring MVC mybatis dispacherServlet(源码解读)
以下源码版本(4.2.0.RELEASE) dispacherServlet是servlet的实现类,是spring MVC的前端转发器,是spring MVC的核心. 那么它做了哪些事呢? 它主要做 ...
- Spring MVC 中 HandlerInterceptorAdapter的使用
一般情况下,对来自浏览器的请求的拦截,是利用Filter实现的,这种方式可以实现Bean预处理.后处理. Spring MVC的拦截器不仅可实现Filter的所有功能,还可以更精确的控制拦截精度. s ...
- Spring MVC初次相见
1.什么是SpringMvc Spring MVC属于SpringFrameWork的后续产品,已经融合在Spring Web Flow里面.Spring 框架提供了构建 Web 应用程序的全功能 M ...
- Spring Mvc的入门
SpringMVC也叫Spring Web mvc,属于表现层的框架.Spring MVC是Spring框架的一部分,是在Spring3.0后发布的. Spring Web MVC是什么: Sprin ...
- (转载)spring mvc DispatcherServlet详解之一---处理请求深入解析
要深入理解spring mvc的工作流程,就需要先了解spring mvc的架构: 从上图可以看到 前端控制器DispatcherServlet在其中起着主导作用,理解了DispatcherServl ...
随机推荐
- Wince 中如何实现注册表恢复原厂设置
理论: 使用HIVE注册表,系统在完成了第一阶段也就是加载完了boot.hv+binfs之后和加载系统HIVE注册表之前,filesys.exe都会调用OEMIoControl来查询是否需要清除保存在 ...
- Codeforces_GYM Flight Boarding Optimization
(ACM ICPC 2013–2014, NEERC, Northern Subregional Contest) Flight Boarding OptimizationInput file: fl ...
- 求强连通分量模板(tarjan算法)
关于如何求强连通分量的知识请戳 https://www.byvoid.com/blog/scc-tarjan/ void DFS(int x) { dfn[x]=lowlink[x]=++dfn_cl ...
- HDU 1150 Machine Schedule (最小覆盖,匈牙利算法)
题意: 有两台不同机器A和B,他们分别拥有各种运行模式1~n和1~m.现有一些job,需要在某模式下才能完成,job1在A和B上需要的工作模式又可能会不一样.两台机器一开始处于0模式,可以切换模式,但 ...
- vim - 查找替换
:%s/\<key_word_replaced\>/word_you_want_to_say/g
- GBDT(Gradient Boosting Decision Tree)算法&协同过滤算法
GBDT(Gradient Boosting Decision Tree)算法参考:http://blog.csdn.net/dark_scope/article/details/24863289 理 ...
- c& c++ enum
1.为什么要用enum 写程序时,我们常常需要为某个对象关联一组可选alternative属性.例如,学生的成绩分A,B,C,D等,天气分sunny, cloudy, rainy等等. ...
- 通过对源代码的反向工程学习CoreData架构
在本文开始,先给出反向工程后的结果: 不过需要注意,三个实例的指针都被同一个实例拥有,比如三个指针都位于appDelegate. 在AppDelegate类中定义了下面三个属性: @property ...
- hdu 4435 charge-station
// 题意 从1出发逛完N个点回到出发点 要在这N个点选择性建设加油站 车每次加满油最多可以行使D米// 然后最少要花多少钱才能达到上述要求// 注意到 第i个城市的花费是 2^(i-1) 所以 我就 ...
- 【转】【Android】对话框 AlertDialog -- 不错不错
原文网址:http://blog.csdn.net/feng88724/article/details/6171450 本讲介绍一下Android基本组件:对话框AlertDialog. API: j ...