使用fastjson 替换springMvc默认的jackson
来源:互联网 发布:淘宝面试问题及答案 编辑:程序博客网 时间:2024/06/05 02:22
两种方式解决:
一、xml配置方式
<mvc:annotation-driven> <mvc:message-converters register-defaults="true"> <!-- 配置Fastjson支持 --> <bean class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>text/html;charset=UTF-8</value> <value>application/json</value> </list> </property> <property name="features"> <list> <value>WriteMapNullValue</value> <value>QuoteFieldNames</value> </list> </property> </bean> </mvc:message-converters></mvc:annotation-driven>
二、注解方式
/**
* 该类覆盖了原有的HttpMessageConverters,只剩下一个json的处理类,采用fastJson
*/
@Configuration
public class WebConfigure extends WebMvcConfigurerAdapter {
@Beanpublic HttpMessageConverters customConverters() { return new HttpMessageConverters(new FastJsonHttpMessageConverter());}@Overridepublic void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(new AccessInterceptor()).addPathPatterns("/**"); super.addInterceptors(registry);}
}
阅读全文
1 0
- 使用fastjson 替换springMvc默认的jackson
- SpringMVC 3使用Fastjson代替Jackson
- FastJson和Jackson的使用
- SpringMVC整合FastJson:用"最快的json转换工具"替换SpringMVC的默认json转换
- Spring MVC使用fastjson做消息转换器,与默认Jackson的区别
- 使用fastjson 和 jackson的一些方法
- FastJson Jackson Gson使用教程
- 关于fastjson,jackson,struts2插件的使用(仅供参考)
- 在 springmvc 中, 如何配置 fastjson (阿里开源的) 和 Jackson( Spring 内置的)
- SpringMVC杂记(1) 使用阿里巴巴的fastjson
- SpringMVC杂记(1) 使用阿里巴巴的fastjson
- SpringMvc配置使用jackson
- SpringMVC+Jackson的配置
- Jackson使用(四)----springmvc中配置jackson
- fastJson和jackson转json的区别
- jackson和fastjson的效率对比:
- fastjson和jackson的简单对比
- Jackson,Gson,Fastjson的解析时间对比
- Red Hat 7.3 基于本地http搭建YUM
- SSH的统一应用
- 贝塞尔曲线学习【1】
- 'Navigator is deprecated and has been removed from this package. It can now be installed ' +
- magnitude函数
- 使用fastjson 替换springMvc默认的jackson
- UnityShader案例(六)——渐变纹理
- 解决Hibernate:could not initialize proxy
- 使用Nginx+Keepalived组建高可用负载平衡Web server集群
- [Shell]tr命令使用指南
- [Java]集合框架中值得注意的点
- 抓取一些乱的URL
- visual studio监视变量
- Tomcat源码分析-LifecycleMBeanBase