spring webmvc使用ResponseBody前,在配置文件中的配置
生活随笔
收集整理的這篇文章主要介紹了
spring webmvc使用ResponseBody前,在配置文件中的配置
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
spring的版本不同, 導致配置引用地址不同
首先引用一個jar包
<dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-core</artifactId><version>2.5.2</version></dependency><dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-databind</artifactId><version>2.5.2</version></dependency>
?
一. 當前spring版本3.x
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="messageConverters"> <list> <ref bean="jsonHttpMessageConverter" /> </list> </property> </bean> <bean id="jsonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>application/json;charset=UTF-8</value> </list> </property> </bean>
二.當前spring版本4.x
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="messageConverters"> <list> <ref bean="jsonHttpMessageConverter" /> </list> </property> </bean> <bean id="jsonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>application/json;charset=UTF-8</value> </list> </property> </bean>?
轉載于:https://www.cnblogs.com/duwenlei/p/4825368.html
總結
以上是生活随笔為你收集整理的spring webmvc使用ResponseBody前,在配置文件中的配置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C基础--字符串操作函数(strlen,
- 下一篇: Java基础知识强化49:10个实用的但