springboot配置fastjson后端往前端传输格式化
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.context.annotation.Bean;
import org.springframework.http.converter.HttpMessageConverter; import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.support.config.FastJsonConfig;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
@Bean
public HttpMessageConverters fastJsonHttpMessageConverters() {
// 1、需要先定义一个 convert 转换消息的对象;
FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter(); //2、添加fastJson 的配置信息,比如:是否要格式化返回的json数据;
FastJsonConfig fastJsonConfig = new FastJsonConfig();
fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat); //3、在convert中添加配置信息.
fastConverter.setFastJsonConfig(fastJsonConfig); HttpMessageConverter<?> converter = fastConverter;
return new HttpMessageConverters(converter);
}
springboot配置fastjson后端往前端传输格式化的更多相关文章
- 十七、springboot配置FastJson为Spring Boot默认JSON解析框架
前提 springboot默认自带json解析框架,默认使用jackson,如果使用fastjson,可以按照下列方式配置使用 1.引入fastjson依赖库: maven: <dependen ...
- springboot上传文件 & 不配置虚拟路径访问服务器图片 & springboot配置日期的格式化方式 & Springboot配置日期转换器
1. Springboot上传文件 springboot的文件上传不用配置拦截器,其上传方法与SpringMVC一样 @RequestMapping("/uploadPicture&q ...
- SpringBoot阿里巴巴Fastjson的一些常用配置
SpringBoot阿里巴巴Fastjson的一些常用配置 @Bean public HttpMessageConverters fastJsonHttpMessageConverters() { F ...
- SpringBoot中使用Fastjson/Jackson对JSON序列化格式化输出的若干问题
来源 :https://my.oschina.net/Adven/blog/3036567 使用springboot-web编写rest接口,接口需要返回json数据,目前国内比较常用的fastjso ...
- 【Springboot】FastJson与Jackson全局序列化方式的配置和相关工具类
springboot 版本: <parent> <groupId>org.springframework.boot</groupId> <artifactId ...
- spring boot @ResponseBody转换JSON 时 Date 类型处理方法,Jackson和FastJson两种方式,springboot 2.0.9配置fastjson不生效官方解决办法
spring boot @ResponseBody转换JSON 时 Date 类型处理方法 ,这里一共有两种不同解析方式(Jackson和FastJson两种方式,springboot我用的1.x的版 ...
- 关于JavaDate数据返回到前端变数字的问题(并引申到前后端时间的传输)
不知道为什么,前端显示的所有数据项都没有错,就只有时间那一项很奇怪,是一串数字,而且这个数字在数据库怎么都找不到…… 然后我在后端从service到controller都debug了一遍,发现数据都没 ...
- springboot(四).配置FastJson自定义消息转化器
配置FastJson自定义消息转化器 一.fastJson简介 fastJson是阿里巴巴旗下的一个开源项目之一,顾名思义它专门用来做快速操作Json的序列化与反序列化的组件.它是目前json解析最快 ...
- springboot+apache前后端分离部署https
目录 1. 引言 2. 了解https.证书.openssl及keytool 2.1 https 2.1.1 什么是https 2.1.2 https解决什么问题 2.2 证书 2.2.1 证书内容 ...
随机推荐
- BZOJ 3210: 花神的浇花集会
3210: 花神的浇花集会 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 577 Solved: 299[Submit][Status][Discus ...
- FourAndSix: 2.01靶机入侵
0x01 前言 FourAndSix2是易受攻击的一个靶机,主要任务是通过入侵进入到目标靶机系统然后提权,并在root目录中并读取flag.tx信息 FourAndSix2.镜像下载地址: htt ...
- Android Studio 使用VCS版本控制
1.SVN的配置: 如果项目使用的是SVN配置,那么除了乌龟SVN GUI工具外,你还得下载Subversion, 因为AS要用其中的xx.exe命令行执行程序, 下载地址:https://www.v ...
- Google Gson用法
the latest version is 2.8.0. If you're using Gradle, add the following line: compile 'com.google.cod ...
- bzoj4784【zjoi2017】仙人掌
题目描述 如果一个无自环无重边无向连通图的任意一条边最多属于一个简单环,我们就称之为仙人掌.所谓简单环即不经过 重复的结点的环. 现在九条可怜手上有一张无自环无重边的无向连通图,但是她觉得这张图中的边 ...
- PHP发送HTTP请求的几种方式
转发:https://blog.tanteng.me/2017/07/php-curl-guzzlehttp/ 1)PHP开发中我们常用CURL 方式封装 HTTP请求,什么是CURL? CURL 是 ...
- SIFT算法学习
几个关于SIFT算法的blog,写的很好,链接学习一下 小北的家谈谈SIFT.PCA-SIFT.SURF及我的一点思考http://blog.csdn.net/ijuliet/article/deta ...
- Spyder使用IPython Console弹出绘图窗口的设置方法
http://www.datastudy.cc/article/3cfc3aff3b2c5948b938456e00376276 在使用Spyder的过程中,因为它的绘图,默认是绘图在IPython窗 ...
- 用nginx搭建简单的文件下载服务器
server { listen 80; #端口 server_name localhost; #服务名 charset utf-8; # ...
- Table of Contents
程序设计 Java JavaSE Apache Commons Servlet & JSP Maven JMS ActiveMQ WebService CXF Jersey HttpClien ...