springmvc标签<mvc:annotation-driven/>(十二)
来源:互联网 发布:表白网站整站源码 编辑:程序博客网 时间:2024/05/29 10:58
原来的springmvc.xml配置
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd"> <!-- 开启扫描 com.study下的包,如果扫描到有@Component @Controller@Service等这些注解的类,则把这些类注册为bean --> <context:component-scan base-package="com.study"></context:component-scan> <!-- 配置注解处理器映射器 功能:寻找执行类Controller--> <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"></bean> <!-- 配置注解处理器适配器 功能:调用controller方法,执行controller--> <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"></bean> <!-- 配置sprigmvc视图解析器:解析逻辑试图 后台返回逻辑试图:index 视图解析器解析出真正物理视图:前缀+逻辑试图+后缀====/WEB-INF/jsps/index.jsp --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsps/"></property> <property name="suffix" value=".jsp"></property> </bean></beans>
使用<mvc:annotation-driven/>
标签后简化为
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd"> <!-- 开启扫描 com.study下的包,如果扫描到有@Component @Controller@Service等这些注解的类,则把这些类注册为bean --> <context:component-scan base-package="com.study"></context:component-scan> <!-- annotation-driven:默认创建了多个对象:RequestMappingHandlerMapping,RequestMappingHandlerAdapter 也提供对json格式支持--> <mvc:annotation-driven/> <!-- 配置sprigmvc视图解析器:解析逻辑试图 后台返回逻辑试图:index 视图解析器解析出真正物理视图:前缀+逻辑试图+后缀====/WEB-INF/jsps/index.jsp --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsps/"></property> <property name="suffix" value=".jsp"></property> </bean></beans>
注: annotation-driven:默认创建了多个对象:RequestMappingHandlerMapping,RequestMappingHandlerAdapter
也提供对json格式支持
阅读全文
0 0
- springmvc标签<mvc:annotation-driven/>(十二)
- SpringMVC—<mvc:annotation-driven/>标签
- SpringMVC 解读之<mvc:annotation-driven/>标签
- SpringMVC 解读之<mvc:annotation-driven/>标签
- SpringMVC-->mvc:annotation-driven
- SpringMVC学习(六) 关于mvc:annotation-driven标签
- SpringMVC-07 mvc:annotation-driven
- 【springmvc解读】<mvc:annotation-driven/>
- SpringMVC之mvc:annotation-driven
- mvc annotation-driven 新增标签
- <mvc:annotation-driven/>标签说明
- springMVC实现首页的重定向(<mvc:view-controller>以及<mvc:annotation-driven/>标签使用)
- SpringMVC 解读——<mvc:annotation-driven/>
- ajax请求springmvc与mvc:annotation-driven
- SpringMVC 解读——<mvc:annotation-driven/>
- SpringMVC-<mvc:annotation-driven>的作用
- springmvc显示json数据 :<mvc:annotation-driven>
- SpringMVC 解读——<mvc:annotation-driven/>
- 实训--day10
- Linux内核工程导论——linux学习和职业曲线(初学者,中级,高级都可参考)
- BeautifulSoup学习之CSS选择器
- js技术--正则表达式
- httpclient
- springmvc标签<mvc:annotation-driven/>(十二)
- hibernate异常 Session was already closed
- react native打包出现unable to process incoming event 'ProcessComplete' <ProgressCompleteEvent>
- iOS app崩溃率,如何解决线上闪退
- lucene和elasticsearch的前世今生、elasticsearch的核心概念、elasticsearch核心概念 vs. 数据库核心概念(来自学习资料)
- 2017-7-20总结
- Permission denied (publickey).fatal: Could not read from remote repository.
- 安装Docker环境来使用Battery History
- java并发编程实战-性能与可伸缩性1