spring mvc <mvc:annotation-driven/> 和<context:component-scan base-package=""/>解释
来源:互联网 发布:安知玉如意百度云 编辑:程序博客网 时间:2024/06/03 02:09
1. <mvc:annotation-driven/> 为springmvc注解驱动
可代替
<!-- 注解处理器映射器 -->
<bean
class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping">
</bean>
<!-- 注解适配器 -->
<bean
class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
<!-- 在webBindingInitializer中注入自定义属性编辑器、自定义转换器 -->
<property name="webBindingInitializer" ref="customBinder"></property>
</bean>
的配置
2 <context:component-scan base-package=""/> 扫描器(如果有了扫描器,可以不加注解驱动)
1><mvc:annotation-driven/>会自动注册DefaultAnnotationHandlerMapping与AnnotationMethodHandlerAdapter 两个bean
DefaultAnnotationHandlerMapping :负责扫描带有@Controller注解的类,给此类设置对应的@RequestMapping
AnnotationMethodHandlerAdapter :负责扫描Controller类中的方法,给方法设置对应的@RequestMapping
2><context:component-scan base-package=""></context:component-scan>
扫描器会扫描带有@Component@Service@Controller@Component等注解,并实现相应的操作,
因为这四个注解包含了@Controller,
所以会将Controller类和方法进行映射,不需要用<mvc:annotation-driven/>了
- spring mvc <mvc:annotation-driven/> 和<context:component-scan base-package=""/>解释
- <mvc:annotation-driven/>、<context:component-scan base-package=""/>、<context:annotation-config/>的用法
- <mvc:annotation-driven/>、<context:component-scan base-package=""/>、<context:annotation-config/>的用法
- <mvc:annotation-driven/>、<context:component-scan base-package=""/>、<context:annotation-config/>的用法
- [spring-mvc] <context:component-scan/> <mvc:annotation-driven/>
- Spring配置 <context:component-scan/> <mvc:annotation-driven />
- Spring配置 <context:component-scan/> <mvc:annotation-driven />
- spring <context:component-scan />及<mvc:annotation-driven />使用说明
- Spring配置 <context:component-scan/> <mvc:annotation-driven />
- Spring <context:component-scan/>与<mvc:annotation-driven/>
- spring <context:component-scan />及<mvc:annotation-driven />使用说明
- Spring配置 <context:component-scan/> <mvc:annotation-driven />
- 剖析<context:component-scan/>、<mvc:annotation-driven/>
- <context:component-scan/> <mvc:annotation-driven />
- <context:component-scan/> <mvc:annotation-driven /> 区别
- spring mvc 中mvc:annotation-driven和context:component-scan区别
- <context:component-scan/>和<mvc:annotation-driven/>的区别
- <context:component-scan/>和<mvc:annotation-driven/>的区别
- Redis数据类型-String
- 大数 斐波那契 与阶乘
- tableView内的View悬停在导航栏的效果
- 常见的Python面试题+详细解答
- Python爬虫爬取Html中的Url常用知识
- spring mvc <mvc:annotation-driven/> 和<context:component-scan base-package=""/>解释
- Redis数据类型-List
- 修复miniblink无法显示某个网站的某个图标的bug
- Codeforces 742B B. Arpa’s obvious problem and Mehrdad’s terrible solution
- android入门小知识
- Tablayout使用小结
- 第十二章-无线传感网接入Internet
- 常见对象_BigDecimal的加减乘除法的使用
- Android 中使用MediaRecorder进行录像详解(视频录制)