feat:jwt中的hutool-json改为fastjson
This commit is contained in:
@@ -1,14 +1,17 @@
|
||||
package com.tiesheng.demo.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.date.TimeInterval;
|
||||
import cn.hutool.log.LogFactory;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.context.AnalysisContext;
|
||||
import com.alibaba.excel.read.listener.ReadListener;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.tiesheng.annotation.role.RoleAuthority;
|
||||
import com.tiesheng.annotation.token.TokenIgnore;
|
||||
import com.tiesheng.database.config.DbBackupConfig;
|
||||
import com.tiesheng.demo.pojos.JsonTest;
|
||||
import com.tiesheng.demo.pojos.PoiBean;
|
||||
import com.tiesheng.demo.pojos.TestFile;
|
||||
import com.tiesheng.platform.config.ding.PlatformDingConfig;
|
||||
@@ -21,16 +24,11 @@ import com.tiesheng.util.pojos.ApiResp;
|
||||
import com.tiesheng.util.pojos.FileUploadPath;
|
||||
import com.tiesheng.util.service.TsCacheService;
|
||||
import com.tiesheng.web.service.CoreLogService;
|
||||
import com.tiesheng.web.util.ProcessImportConsumer;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -69,7 +67,16 @@ public class TestController {
|
||||
@RequestMapping("/redirect")
|
||||
@TokenIgnore
|
||||
@RoleAuthority("redirect")
|
||||
public ApiResp<String> redirect(HttpServletResponse response) {
|
||||
public ApiResp<JsonTest> redirect(@RequestBody JsonTest dto, HttpServletResponse response) {
|
||||
|
||||
JsonTest jsonTest = new JsonTest();
|
||||
jsonTest.setNow(DateUtil.date());
|
||||
jsonTest.setNow1(DateUtil.date());
|
||||
|
||||
String jsonString = JSON.toJSONString(jsonTest);
|
||||
LogFactory.get().info(jsonString);
|
||||
|
||||
LogFactory.get().info(JSON.toJSONString(dto));
|
||||
|
||||
// ArrayList<String> strings = CollUtil.newArrayList("11111", "22222");
|
||||
// coreLogService.addProcess("fdfd", strings, new ProcessImportConsumer<String>() {
|
||||
@@ -91,7 +98,7 @@ public class TestController {
|
||||
|
||||
// tsTokenConfig.validToken("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2NzYwMDY4NzUsImlkIjoiMSIsImVudmlyb25tZW50VHlwZSI6Im1vYmlsZSIsInNlcnZpY2UiOiJjb250ZXN0LXJlc2VydmUiLCJleHRyYSI6IiJ9.nsfxEFpCNHC7eNCS5DJXdu1VDdnHrTjSfgrozND70Lc", true);
|
||||
// globalConfig.redirect("mobile", "/test", response);
|
||||
return ApiResp.respOK("");
|
||||
return ApiResp.respOK(jsonTest);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.tiesheng.demo.pojos;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class JsonTest {
|
||||
|
||||
private Date now;
|
||||
@JSONField(format = "yyyy-MM-dd")
|
||||
private Date now1;
|
||||
private String no;
|
||||
private String name;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter\getter
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public Date getNow() {
|
||||
return now;
|
||||
}
|
||||
|
||||
public void setNow(Date now) {
|
||||
this.now = now;
|
||||
}
|
||||
|
||||
public Date getNow1() {
|
||||
return now1;
|
||||
}
|
||||
|
||||
public void setNow1(Date now1) {
|
||||
this.now1 = now1;
|
||||
}
|
||||
|
||||
public String getNo() {
|
||||
return no;
|
||||
}
|
||||
|
||||
public void setNo(String no) {
|
||||
this.no = no;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.tiesheng.demo.pojos;
|
||||
|
||||
import com.tiesheng.annotation.desensitize.Desensitize;
|
||||
import com.tiesheng.poi.pojos.PoiWriteBase;
|
||||
|
||||
|
||||
@@ -8,7 +7,6 @@ public class TestParent implements PoiWriteBase {
|
||||
|
||||
private String id;
|
||||
|
||||
@Desensitize()
|
||||
private String test;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.tiesheng.annotation.desensitize;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* @author hao
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Desensitize {
|
||||
|
||||
int prefix() default 1;
|
||||
|
||||
int suffix() default 1;
|
||||
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package com.tiesheng.encrypt.config;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.tiesheng.util.config.EncryptConfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.MethodParameter;
|
||||
@@ -66,7 +66,7 @@ public class DecryptRequestBodyAdvice implements RequestBodyAdvice {
|
||||
DecryptHttpInputMessage(HttpInputMessage inputMessage, EncryptConfig encryptConfig) throws Exception {
|
||||
this.headers = inputMessage.getHeaders();
|
||||
String bodyStr = IoUtil.read(inputMessage.getBody(), CharsetUtil.CHARSET_UTF_8);
|
||||
String encryptData = JSONUtil.parseObj(bodyStr).getStr("encryptData");
|
||||
String encryptData = JSON.parseObject(bodyStr).getString("encryptData");
|
||||
if (!StrUtil.isEmpty(encryptData)) {
|
||||
String decrypt = encryptConfig.decrypt(encryptData);
|
||||
this.body = IoUtil.toStream(decrypt, Charset.defaultCharset());
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.tiesheng.encrypt.config;
|
||||
|
||||
import cn.hutool.core.annotation.AnnotationUtil;
|
||||
import cn.hutool.log.LogFactory;
|
||||
import com.tiesheng.util.CommonUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.tiesheng.util.config.EncryptConfig;
|
||||
import com.tiesheng.util.pojos.ApiResp;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -42,7 +42,7 @@ public class EncryptResponseBodyAdvice implements ResponseBodyAdvice<ApiResp> {
|
||||
}
|
||||
|
||||
body.setEncrypt(true);
|
||||
body.setData(encryptConfig.encrypt(CommonUtil.writeJsonString(data)));
|
||||
body.setData(encryptConfig.encrypt(JSON.toJSONString(data)));
|
||||
return body;
|
||||
} catch (Exception var17) {
|
||||
LogFactory.get().info("加密数据异常", var17);
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
package com.tiesheng.util;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.alibaba.fastjson.support.config.FastJsonConfig;
|
||||
import com.tiesheng.util.config.DesensitizeValueFilter;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class CommonUtil {
|
||||
|
||||
|
||||
/**
|
||||
* FastJson配置
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static FastJsonConfig fastJsonConfig() {
|
||||
FastJsonConfig config = new FastJsonConfig();
|
||||
config.setSerializerFeatures(SerializerFeature.WriteMapNullValue,
|
||||
SerializerFeature.WriteNullStringAsEmpty,
|
||||
SerializerFeature.WriteEnumUsingName,
|
||||
SerializerFeature.DisableCircularReferenceDetect
|
||||
);
|
||||
config.setDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
config.setSerializeFilters(new DesensitizeValueFilter());
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 格式化数据
|
||||
*
|
||||
* @param value
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String writeJsonString(Object value) throws IOException {
|
||||
FastJsonConfig fastJsonConfig = fastJsonConfig();
|
||||
ByteArrayOutputStream outnew = new ByteArrayOutputStream();
|
||||
JSON.writeJSONStringWithFastJsonConfig(outnew, fastJsonConfig.getCharset(),
|
||||
value, fastJsonConfig.getSerializeConfig(),
|
||||
fastJsonConfig.getSerializeFilters(),
|
||||
fastJsonConfig.getDateFormat(), JSON.DEFAULT_GENERATE_FEATURE,
|
||||
fastJsonConfig.getSerializerFeatures());
|
||||
return outnew.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.tiesheng.util.config;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.serializer.ValueFilter;
|
||||
import com.tiesheng.annotation.desensitize.Desensitize;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/**
|
||||
* 脱敏过滤类
|
||||
*
|
||||
* @author hao
|
||||
*/
|
||||
public class DesensitizeValueFilter implements ValueFilter {
|
||||
|
||||
@Override
|
||||
public Object process(Object object, String name, Object value) {
|
||||
if (ObjectUtil.isEmpty(value) || !(value instanceof String)) {
|
||||
return value;
|
||||
}
|
||||
|
||||
Field field = ReflectUtil.getField(object.getClass(), name);
|
||||
if (ObjectUtil.isEmpty(field)) {
|
||||
return value;
|
||||
}
|
||||
Desensitize desensitize = field.getAnnotation(Desensitize.class);
|
||||
if (String.class != field.getType() || ObjectUtil.isEmpty(desensitize)) {
|
||||
return value;
|
||||
}
|
||||
String originVal = String.valueOf(value);
|
||||
return StrUtil.hide(originVal, desensitize.prefix(),
|
||||
StrUtil.length(originVal) - desensitize.suffix());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,8 @@ import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.hutool.log.LogFactory;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.tiesheng.util.exception.ApiException;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -26,6 +28,18 @@ import java.util.List;
|
||||
@ConfigurationProperties(prefix = "tiesheng.global")
|
||||
public class GlobalConfig {
|
||||
|
||||
static {
|
||||
JSON.DEFFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
// FASTJSON 设置全局序列化配置
|
||||
JSON.DEFAULT_GENERATE_FEATURE |= SerializerFeature.WriteMapNullValue.getMask();
|
||||
JSON.DEFAULT_GENERATE_FEATURE |= SerializerFeature.WriteNullStringAsEmpty.getMask();
|
||||
JSON.DEFAULT_GENERATE_FEATURE |= SerializerFeature.WriteEnumUsingName.getMask();
|
||||
JSON.DEFAULT_GENERATE_FEATURE |= SerializerFeature.WriteDateUseDateFormat.getMask();
|
||||
JSON.DEFAULT_GENERATE_FEATURE |= SerializerFeature.DisableCircularReferenceDetect.getMask();
|
||||
}
|
||||
|
||||
|
||||
private String host;
|
||||
private String service;
|
||||
private String version;
|
||||
|
||||
@@ -4,7 +4,7 @@ package com.tiesheng.util.config;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.tiesheng.util.exception.ApiException;
|
||||
import com.tiesheng.util.jwt.JWT;
|
||||
import com.tiesheng.util.jwt.JWTValidator;
|
||||
@@ -81,7 +81,7 @@ public class TsTokenConfig {
|
||||
try {
|
||||
JWT decode = JWT.of(token);
|
||||
JWTValidator.of(decode).validateDate();
|
||||
tokenBean = JSONUtil.toBean(decode.getPayloads(), TokenBean.class);
|
||||
tokenBean = JSON.toJavaObject(decode.getPayloads(), TokenBean.class);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package com.tiesheng.util.jwt;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.date.format.GlobalCustomFormat;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.json.JSONConfig;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.nio.charset.Charset;
|
||||
@@ -21,9 +19,6 @@ import java.util.Map;
|
||||
public class Claims implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// 时间使用秒级时间戳表示
|
||||
private final JSONConfig CONFIG = JSONConfig.create().setDateFormat(GlobalCustomFormat.FORMAT_SECONDS);
|
||||
|
||||
private JSONObject claimJSON;
|
||||
|
||||
/**
|
||||
@@ -39,7 +34,7 @@ public class Claims implements Serializable {
|
||||
claimJSON.remove(name);
|
||||
return;
|
||||
}
|
||||
claimJSON.set(name, value);
|
||||
claimJSON.put(name, value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,7 +58,7 @@ public class Claims implements Serializable {
|
||||
*/
|
||||
public Object getClaim(String name) {
|
||||
init();
|
||||
return this.claimJSON.getObj(name);
|
||||
return this.claimJSON.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,7 +78,7 @@ public class Claims implements Serializable {
|
||||
* @param charset 编码
|
||||
*/
|
||||
public void parse(String tokenPart, Charset charset) {
|
||||
this.claimJSON = JSONUtil.parseObj(Base64.decodeStr(tokenPart, charset), CONFIG);
|
||||
this.claimJSON = JSON.parseObject(Base64.decodeStr(tokenPart, charset));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -94,7 +89,7 @@ public class Claims implements Serializable {
|
||||
|
||||
private void init() {
|
||||
if (null == this.claimJSON) {
|
||||
this.claimJSON = new JSONObject(CONFIG);
|
||||
this.claimJSON = new JSONObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.CharUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.tiesheng.util.jwt.signers.AlgorithmUtil;
|
||||
import com.tiesheng.util.jwt.signers.JWTSigner;
|
||||
import com.tiesheng.util.jwt.signers.JWTSignerUtil;
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
package com.tiesheng.util.jwt;
|
||||
|
||||
import com.tiesheng.util.jwt.signers.JWTSigner;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* JSON Web Token (JWT)工具类
|
||||
*/
|
||||
public class JWTUtil {
|
||||
|
||||
/**
|
||||
* 创建HS256(HmacSHA256) JWT Token
|
||||
*
|
||||
* @param payload 荷载信息
|
||||
* @param key HS256(HmacSHA256)密钥
|
||||
* @return JWT Token
|
||||
*/
|
||||
public static String createToken(Map<String, Object> payload, byte[] key) {
|
||||
return createToken(null, payload, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建HS256(HmacSHA256) JWT Token
|
||||
*
|
||||
* @param headers 头信息
|
||||
* @param payload 荷载信息
|
||||
* @param key HS256(HmacSHA256)密钥
|
||||
* @return JWT Token
|
||||
*/
|
||||
public static String createToken(Map<String, Object> headers, Map<String, Object> payload, byte[] key) {
|
||||
return JWT.create()
|
||||
.addHeaders(headers)
|
||||
.addPayloads(payload)
|
||||
.setKey(key)
|
||||
.sign();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建JWT Token
|
||||
*
|
||||
* @param payload 荷载信息
|
||||
* @param signer 签名算法
|
||||
* @return JWT Token
|
||||
*/
|
||||
public static String createToken(Map<String, Object> payload, JWTSigner signer) {
|
||||
return createToken(null, payload, signer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建JWT Token
|
||||
*
|
||||
* @param headers 头信息
|
||||
* @param payload 荷载信息
|
||||
* @param signer 签名算法
|
||||
* @return JWT Token
|
||||
*/
|
||||
public static String createToken(Map<String, Object> headers, Map<String, Object> payload, JWTSigner signer) {
|
||||
return JWT.create()
|
||||
.addHeaders(headers)
|
||||
.addPayloads(payload)
|
||||
.setSigner(signer)
|
||||
.sign();
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析JWT Token
|
||||
*
|
||||
* @param token token
|
||||
* @return {@link JWT}
|
||||
*/
|
||||
public static JWT parseToken(String token) {
|
||||
return JWT.of(token);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证JWT Token有效性
|
||||
*
|
||||
* @param token JWT Token
|
||||
* @param key HS256(HmacSHA256)密钥
|
||||
* @return 是否有效
|
||||
*/
|
||||
public static boolean verify(String token, byte[] key) {
|
||||
return JWT.of(token).setKey(key).verify();
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证JWT Token有效性
|
||||
*
|
||||
* @param token JWT Token
|
||||
* @param signer 签名器
|
||||
* @return 是否有效
|
||||
*/
|
||||
public static boolean verify(String token, JWTSigner signer) {
|
||||
return JWT.of(token).verify(signer);
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,13 @@ package com.tiesheng.web.config.exception;
|
||||
|
||||
import cn.hutool.core.exceptions.ValidateException;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.tiesheng.web.service.TieshengWebConfigurer;
|
||||
import com.tiesheng.util.exception.ApiException;
|
||||
import com.tiesheng.util.exception.ApiRespEnum;
|
||||
import com.tiesheng.util.pojos.ApiResp;
|
||||
import com.tiesheng.web.service.TieshengWebConfigurer;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.web.servlet.MultipartProperties;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.validation.FieldError;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
@@ -55,6 +56,9 @@ public class SpringExceptionHandler {
|
||||
}
|
||||
return ApiResp.respCust(ApiRespEnum.BadRequest.getCode(), msg);
|
||||
}
|
||||
if (e instanceof HttpMessageNotReadableException) {
|
||||
return ApiResp.respCust(ApiRespEnum.BadRequest.getCode(), "参数格式不正确");
|
||||
}
|
||||
if (e instanceof MethodArgumentTypeMismatchException) {
|
||||
return ApiResp.respCust(ApiRespEnum.BadRequest.getCode(), "请求参数不合法");
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package com.tiesheng.web.config.json;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.support.config.FastJsonConfig;
|
||||
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
|
||||
import com.tiesheng.util.CommonUtil;
|
||||
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -25,12 +26,15 @@ public class FastJsonMessageConverter {
|
||||
@Bean
|
||||
public HttpMessageConverters fastJsonHttpMessageConverters() {
|
||||
|
||||
FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
|
||||
fastConverter.setFastJsonConfig(CommonUtil.fastJsonConfig());
|
||||
fastConverter.setDefaultCharset(StandardCharsets.UTF_8);
|
||||
FastJsonConfig config = new FastJsonConfig();
|
||||
config.setDateFormat(JSON.DEFFAULT_DATE_FORMAT);
|
||||
|
||||
List<MediaType> mediaTypes = new ArrayList<>();
|
||||
mediaTypes.add(MediaType.APPLICATION_JSON);
|
||||
|
||||
FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
|
||||
fastConverter.setFastJsonConfig(config);
|
||||
fastConverter.setDefaultCharset(StandardCharsets.UTF_8);
|
||||
fastConverter.setSupportedMediaTypes(mediaTypes);
|
||||
|
||||
return new HttpMessageConverters(fastConverter);
|
||||
|
||||
Reference in New Issue
Block a user