Spring MVC: step by step 5-BeanNameUrlHandlerMapping(我的最爱)
来源:互联网 发布:网络专题的类型有哪些 编辑:程序博客网 时间:2024/04/29 03:53
BeanNameUrlHandlerMapping将request url 与bean name直接关联起来。我们就可以在url中直接写上controller的名字,管理起来非常便捷,就像struts,webwork的action一样。
Admin-servlet.xml
<bean id="handlerMapping" class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/>
<bean id="paraResolver" class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver">
<property name="paramName">
<value>method</value>
</property>
<property name="defaultMethodName">
<value>getDefaultView</value>
</property>
</bean>
<bean name="/helloParaController.form" id="helloParaController.form" class="multimvc.HelloParaMutiController" >
<property name="methodNameResolver" ref="paraResolver" />
</bean>
<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.InternalResourceView"/>
<property name="suffix" value=".jsp"/>
</bean>
请求:
<form name="hello" id="hello" action="/SpringBeanName/helloParaController.form?method=goFirst" method="post">
form的请求被分配给HelloParaMutiController.goFirst方法。
public class HelloParaMutiController extends MultiActionController {
。。。。
public ModelAndView goFirst(HttpServletRequest request,
HttpServletResponse response) {
ModelAndView mav = new ModelAndView();
mav.setViewName("mutipage/first");
mav.addObject("message", "Hello World!");
return mav;
}
。。。。
}
- Spring MVC: step by step 5-BeanNameUrlHandlerMapping(我的最爱)
- Spring MVC Step by Step
- Spring MVC step by step 1--DispatcherServlet
- Spring MVC: step by step 2-SimpleUrlHandlerMapping
- Spring mvc: step by step 4-MultiActionController
- Spring MVC: step by step 3-Simple Controller
- Developing a Spring Framework MVC application step-by-step
- Developing a Spring Framework MVC application step-by-step
- intellij + gradle + jetty + spring mvc step by step - 1
- intellij + gradle + jetty + spring mvc step by step - 2
- MVC Music Store Step-by-Step Tutorial
- Learning MVC 3.0 Step by Step
- 我要地图Step By Step!
- Spring Aop Step-By-Step 学习笔记
- Step by Step into Spring(IOC)
- Step by Step into Spring (AOP)
- Step by Step into Spring (事务)
- SSH2 Step by Step- Step 4 - Struts2、Spring和Hibernate的整合
- 进程上下文和中断上下文
- 6大代码搜索引擎推荐
- pthread_join pthread_exit pthread_detach
- java打jar包,引用其他.jar文件
- 条件变量
- Spring MVC: step by step 5-BeanNameUrlHandlerMapping(我的最爱)
- 在vs环境中两项目删除其中一个项目解决方案不显示的问题
- VPS介绍
- sscanf()
- 开发板硬件XSBase255(XScale PXA255 Evaluation Board)
- php 学习简单备忘(一)
- scanf()
- 自己写的alarm_cond
- C++实现文本文件的追加呢