浏览 3412 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2017-07-13
2、升级spring xmlns 版本由3.X.xsd升级到4.X.xsd 3、多视图org.springframework.http.converter.json.MappingJacksonHttpMessageConverter升级org.springframework.http.converter.json.MappingJackson2HttpMessageConverter <pre name="code" class="java"> <bean class="com.fasterxml.jackson.databind.ObjectMapper" id="objectMapper"> <!-- 处理responseBody 里面日期类型 --> <property name="dateFormat"> <bean class="java.text.SimpleDateFormat"> <constructor-arg index="0" type="java.lang.String" value="yyyy-MM-dd HH:mm:ss" /> </bean> </property> <property name="serializationInclusion"> <value type="com.fasterxml.jackson.annotation.JsonInclude.Include">NON_EMPTY</value> </property> </bean> <mvc:annotation-driven> <mvc:message-converters> <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>application/json;charset=UTF-8</value> </list> </property> <property name="objectMapper"> <ref bean="objectMapper" /> </property> </bean> <bean class="org.springframework.http.converter.StringHttpMessageConverter"> <!--避免出现乱码 --> <constructor-arg value="UTF-8" index="0"></constructor-arg> <property name="supportedMediaTypes"> <list> <value>text/plain;charset=UTF-8</value> </list> </property> </bean> </mvc:message-converters> </mvc:annotation-driven> </pre> 4、org.springframework.web.servlet.view.ContentNegotiatingViewResolver属性defaultViews 由org.springframework.web.servlet.view.json.MappingJacksonJsonView变更org.springframework.web.servlet.view.json.MappingJackson2JsonView; 以前属性: <property name="ignoreAcceptHeader" value="true" /> <property name="defaultContentType" value="text/html" /> <property name="mediaTypes"> <map> <entry key="json" value="application/json;charset=UTF-8" /> <entry key="xml" value="application/xml;charset=UTF-8" /> </map> </property> <property name="favorParameter" value="false" /> 变更 <pre name="code" class="java"> <bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean"> <property name="favorPathExtension" value="true" /> <property name="ignoreAcceptHeader" value="true"/> <property name="useJaf" value="false"/> <property name="defaultContentType" value="text/html" /> <property name="mediaTypes"> <map> <entry key="html" value="text/html"/> <entry key="json" value="application/json;charset=UTF-8" /> <entry key="xml" value="application/xml;charset=UTF-8" /> </map> </property> </bean> <bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"> <property name="contentNegotiationManager" ref="contentNegotiationManager"/> <property name="viewResolvers"> ................................. </pre> 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |