SPRING MVC3.2案例讲解---配置
来源:互联网 发布:淘宝店铺推广技巧 编辑:程序博客网 时间:2024/05/20 17:23
spring-mvc-showcase-master 是官网上关于spring mvc使用的showcase, 包含了各种spring mvc的使用案例; 配置:
- 使用MAVEN进行工程管理
- 官网使用的MAVEN JDK为1.6,我降级为1.5见POM.xml文件
- 使用TOMCAT6来做J2EE应用服务器插件,见POM.xml文件
- Jackson JSON Processor升级使用2.1.5,案例中使用1.8.1
- SPRING MVC配置上的改变 :使用来进行配置MVC相关信息,跟以前不同;内容改变见http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd 和servlet-context.xml
- <mvc:annotation-driven/>中包含了很多默认的设置:如默认使用MappingJackson2HttpMessageConverter来处理application/json的数据;
spring3以前的配置习惯:
<!-- RESTFUL SPRING 3 --><beanclass="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping" /><beanclass="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"><property name="messageConverters"><list><ref bean="jsonConverter" /></list></property></bean><bean id="jsonConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" />