springmvc学习3:处理器映射器和适配器
来源:互联网 发布:使命召唤5枪支数据 编辑:程序博客网 时间:2024/04/26 01:51
一、非注解处理器映射器和适配器
1.非注解的处理器映射器
1)org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping
2)另一个映射器:org.springframework.web.servlet.handler.SimpleUrlHandlerMapping
SimpleUrlHandlerMapping是BeanNameUrlHandlerMapping的增强版本,它可以将url和处理器bean的id进行统一映射配置。
多个映射器可以并存,前端控制器判断url能让哪个映射器映射,就让正确的映射器处理。
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"><property name="mappings"><props><!-- 对itemsController1进行url映射,url是/queryItems1.action --><prop key="/queryItems1.action">itemController1<prop/><prop key="/queryItems2.action">itemController1<prop/></props></property></bean>
2.非注解的处理器适配器
1)org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter:要求编写的Handler实现Controller接口
2)org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter:要求编写的Handler实现HttpRequestHandler接口。
二、注解的处理器映射器和适配器
1)介绍
在spring3.1之前使用org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping注解映射器,
在spring3.1之后使用org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping注解映射器。
在spring3.1之前使用org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter注解适配器,
在spring3.1之后使用org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter注解适配器。
2)配置
a)方式一(不常用)
<!-- 注解映射器 --><bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/><!-- 注解适配器 --><bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"/>注解的映射器和注解的适配器必须配对使用。
b)方式二(常用)
<mvc:annotation-driven></mvc:annotation-driven>mvc:annotation-driven默认加载很多参数绑定方法,比如json转换就默认加载了。
三、开发注解Handler
1)@RequestMapping("/xxx")
2)spring容器中加载Handler。组件扫描的方式:
<context:component-scan base-package="cn.itcast.ssm.controller"/>
四、配置视图解析器的前缀和后缀
<beanclass="org.springframework.web.servlet.view.InternalResourceViewResolver"><property name="prefix" value="/WEB-INF/"></property><property name="suffix" value=".jsp"></property></bean>
- springmvc学习3:处理器映射器和适配器
- springmvc学习笔记(3)-注解的处理器映射器和适配器
- springmvc学习笔记(3)-注解的处理器映射器和适配器
- springmvc学习笔记(3)-注解的处理器映射器和适配器
- SpringMVC 处理器映射器、处理器适配器
- 非注解和注解的处理器映射器和适配器---SpringMVC学习笔记(三)
- 非注解和注解的处理器映射器和适配器---SpringMVC学习笔记(三)
- 【SpringMVC框架】非注解的处理器映射器和适配器
- 【SpringMVC框架】注解的处理器映射器和适配器配置
- springmvc(三)注解的处理器映射器和适配器
- 【SSM-SpringMVC框架】注解的处理器适配器和映射器
- 【SpringMVC框架】非注解的处理器映射器和适配器
- 【SpringMVC框架】注解的处理器映射器和适配器配置
- SpringMVC - 非注解的处理器映射器和适配器
- springmvc非注解的处理器映射器和适配器
- springmvc注解的处理器映射器和适配器
- springmvc(4)--注解的处理器映射器和适配器
- 深入分析springmvc中的处理器映射器和适配器
- centos 163 yumyuan
- ${pageContext.request.contextPath} JSP取得绝对路径
- C++引用&和指针在作为形参时的区别
- redis队列及多线程应用
- sqlite3数据库的使用
- springmvc学习3:处理器映射器和适配器
- Android高德地图开发(3)——路况+定位
- Hibernate常见的Exception
- iOS 关于屏幕旋转shouldAutorotate
- 基于Spring框架的Shiro配置
- UVALive 7338 C - Toll Management IV
- 8 种 NoSQL 数据库系统对比
- Caffe学习系列(19): 绘制loss和accuracy曲线
- 设计模式之生成器模式