Spring MVC SimpleUrlHandlerMapping example
来源:互联网 发布:外贸英语的软件 编辑:程序博客网 时间:2024/05/19 18:39
In Spring MVC application, the SimpleUrlHandlerMapping
is the most flexible handler mapping class, which allow developer to specify the mapping of URL pattern and handlers explicitly.
The SimpleUrlHandlerMapping
can be declared in two ways.
1. Method 1 – prop key
The property keys are the URL patterns while the property values are the handler IDs or names.
<beans ...> <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="mappings"> <props> <prop key="/welcome.htm">welcomeController</prop> <prop key="/*/welcome.htm">welcomeController</prop> <prop key="/helloGuest.htm">helloGuestController</prop> </props> </property> </bean> <bean id="welcomeController" class="com.mkyong.common.controller.WelcomeController" /> <bean id="helloGuestController" class="com.mkyong.common.controller.HelloGuestController" /></beans>
2. Method 1 – value
The left side are the URL patterns while the right side are the handler IDs or names, separate by a equal symbol “=
”.
<beans ...> <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="mappings"> <value> /welcome.htm=welcomeController /*/welcome.htm=welcomeController /helloGuest.htm=helloGuestController </value> </property> </bean> <bean id="welcomeController" class="com.mkyong.common.controller.WelcomeController" /> <bean id="helloGuestController" class="com.mkyong.common.controller.HelloGuestController" /></beans>
3. Demo
Both are defined the same handler mappings.
/welcome.htm –> welcomeController. /{anything}/welcome.htm –> welcomeController. /helloGuest.htm –> helloGuestController.
0 0
- Spring MVC SimpleUrlHandlerMapping example
- Spring MVC SimpleUrlHandlerMapping example
- Spring MVC: step by step 2-SimpleUrlHandlerMapping
- Spring Web MVC 的HandlerMapping的使用之-------SimpleUrlHandlerMapping(有三种配法)
- Spring 学习笔记-- <mvc:default-servlet-handler />默认加载simpleurlhandlermapping
- Spring Web MVC 的HandlerMapping的使用之-------SimpleUrlHandlerMapping(有三种配法)
- Spring Web MVC 的HandlerMapping的使用之-------SimpleUrlHandlerMapping(有三种配法)
- Spring MVC:使用SimpleUrlHandlerMapping的一个简单例子
- Spring MVC中用SimpleUrlHandlerMapping实现单纯的页面跳转
- Spring MVC - DispatcherServlet Example
- Spring MVC Model Example
- Spring MVC MultiActionController example
- Spring MVC PropertiesMethodNameResolver example
- Spring MVC ParameterMethodNameResolver example
- Spring MVC ParameterMethodNameResolver example
- Spring MVC ParameterizableViewController example
- Spring MVC InternalResourceViewResolver example
- Spring MVC XmlViewResolver example
- 【bzoj1965】【Ahoi2005】【SHUFFLE 洗牌】【快速幂】
- iOS开发系列之Objective-C基础:NSString字符串类型(二)
- swift 类型定义
- mysql数据同步
- 网站每天被抓取新页面的经验心得ccxtqj
- Spring MVC SimpleUrlHandlerMapping example
- Configure the handler mapping priority in Spring MVC
- 网站优化不要经常更换空ccxtqj间
- 3.3 声明和使用常量;3.4 术语
- [150826]Maven详解之聚合与继承
- 【HDOJ 4272】 LianLianKan (vector深搜+剪枝)
- hdu5412--CRB and Queries(整体二分)
- 05==数组(查找,添加,删除,排序)
- ZOJ3876 May Day Holiday