Commit aa5a1186 by zhiheng.zhang

jack 采用jackmapp

parent 1a3523cc
...@@ -16,12 +16,12 @@ import org.springframework.context.annotation.Bean; ...@@ -16,12 +16,12 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
* WebMvcConfigurer * WebMvcConfigurer
*/ */
...@@ -45,35 +45,45 @@ public class WebMvcConfig implements WebMvcConfigurer { ...@@ -45,35 +45,45 @@ public class WebMvcConfig implements WebMvcConfigurer {
objectMapper.registerModule(simpleModule); objectMapper.registerModule(simpleModule);
return objectMapper; return objectMapper;
} }
// @Bean
// public HttpMessageConverter fastjsonHttpMessageConverter() {
// //定义一个转换消息的对象
// FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
//
// //添加fastjson的配置信息 比如 :是否要格式化返回的json数据
// FastJsonConfig fastJsonConfig = new FastJsonConfig();
//
// //过滤并修改配置返回内容
// fastJsonConfig.setSerializerFeatures(
// //List字段如果为null,输出为[],而非null
// //SerializerFeature.WriteNullListAsEmpty,
// //字符类型字段如果为null,输出为"",而非null
//// SerializerFeature.WriteNullStringAsEmpty,
// //Boolean字段如果为null,输出为false,而非null
//// SerializerFeature.WriteNullBooleanAsFalse,
// //SerializerFeature.WriteNullBooleanAsFalse,
// //消除对同一对象循环引用的问题,默认为false(如果不配置有可能会进入死循环)
// SerializerFeature.DisableCircularReferenceDetect,
// SerializerFeature.PrettyFormat
// );
//
// //在转换器中添加配置信息
// fastConverter.setFastJsonConfig(fastJsonConfig);
// List<MediaType> supportedMediaTypes = new ArrayList<>();
// supportedMediaTypes.add(MediaType.APPLICATION_JSON);
// supportedMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
// fastConverter.setSupportedMediaTypes(supportedMediaTypes);
// return fastConverter;
// }
@Bean @Bean
public HttpMessageConverter fastjsonHttpMessageConverter() { public MappingJackson2HttpMessageConverter getMappingJackson2HttpMessageConverter() {
//定义一个转换消息的对象 MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter();
FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter(); //设置中文编码格式
List<MediaType> list = new ArrayList<MediaType>();
//添加fastjson的配置信息 比如 :是否要格式化返回的json数据 list.add(MediaType.APPLICATION_JSON_UTF8);
FastJsonConfig fastJsonConfig = new FastJsonConfig(); mappingJackson2HttpMessageConverter.setSupportedMediaTypes(list);
return mappingJackson2HttpMessageConverter;
//过滤并修改配置返回内容
fastJsonConfig.setSerializerFeatures(
//List字段如果为null,输出为[],而非null
//SerializerFeature.WriteNullListAsEmpty,
//字符类型字段如果为null,输出为"",而非nullF
// SerializerFeature.WriteNullStringAsEmpty,
//Boolean字段如果为null,输出为false,而非null
// SerializerFeature.WriteNullBooleanAsFalse,
//SerializerFeature.WriteNullBooleanAsFalse,
//消除对同一对象循环引用的问题,默认为false(如果不配置有可能会进入死循环)
SerializerFeature.DisableCircularReferenceDetect,
SerializerFeature.PrettyFormat
);
//在转换器中添加配置信息
fastConverter.setFastJsonConfig(fastJsonConfig);
List<MediaType> supportedMediaTypes = new ArrayList<>();
supportedMediaTypes.add(MediaType.APPLICATION_JSON);
supportedMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
fastConverter.setSupportedMediaTypes(supportedMediaTypes);
return fastConverter;
} }
} }
...@@ -16,9 +16,11 @@ import org.springframework.context.annotation.Bean; ...@@ -16,9 +16,11 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.math.BigInteger; import java.math.BigInteger;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -45,35 +47,45 @@ public class WebMvcConfig implements WebMvcConfigurer { ...@@ -45,35 +47,45 @@ public class WebMvcConfig implements WebMvcConfigurer {
objectMapper.registerModule(simpleModule); objectMapper.registerModule(simpleModule);
return objectMapper; return objectMapper;
} }
@Bean // @Bean
public HttpMessageConverter fastjsonHttpMessageConverter() { // public HttpMessageConverter fastjsonHttpMessageConverter() {
//定义一个转换消息的对象 // //定义一个转换消息的对象
FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter(); // FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
//
//添加fastjson的配置信息 比如 :是否要格式化返回的json数据 // //添加fastjson的配置信息 比如 :是否要格式化返回的json数据
FastJsonConfig fastJsonConfig = new FastJsonConfig(); // FastJsonConfig fastJsonConfig = new FastJsonConfig();
//
// //过滤并修改配置返回内容
// fastJsonConfig.setSerializerFeatures(
// //List字段如果为null,输出为[],而非null
// //SerializerFeature.WriteNullListAsEmpty,
// //字符类型字段如果为null,输出为"",而非null
//// SerializerFeature.WriteNullStringAsEmpty,
// //Boolean字段如果为null,输出为false,而非null
//// SerializerFeature.WriteNullBooleanAsFalse,
// //SerializerFeature.WriteNullBooleanAsFalse,
// //消除对同一对象循环引用的问题,默认为false(如果不配置有可能会进入死循环)
// SerializerFeature.DisableCircularReferenceDetect,
// SerializerFeature.PrettyFormat
// );
//
// //在转换器中添加配置信息
// fastConverter.setFastJsonConfig(fastJsonConfig);
// List<MediaType> supportedMediaTypes = new ArrayList<>();
// supportedMediaTypes.add(MediaType.APPLICATION_JSON);
// supportedMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
// fastConverter.setSupportedMediaTypes(supportedMediaTypes);
// return fastConverter;
// }
//过滤并修改配置返回内容 @Bean
fastJsonConfig.setSerializerFeatures( public MappingJackson2HttpMessageConverter getMappingJackson2HttpMessageConverter() {
//List字段如果为null,输出为[],而非null MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter();
//SerializerFeature.WriteNullListAsEmpty, //设置中文编码格式
//字符类型字段如果为null,输出为"",而非null List<MediaType> list = new ArrayList<MediaType>();
// SerializerFeature.WriteNullStringAsEmpty, list.add(MediaType.APPLICATION_JSON_UTF8);
//Boolean字段如果为null,输出为false,而非null mappingJackson2HttpMessageConverter.setSupportedMediaTypes(list);
// SerializerFeature.WriteNullBooleanAsFalse, return mappingJackson2HttpMessageConverter;
//SerializerFeature.WriteNullBooleanAsFalse,
//消除对同一对象循环引用的问题,默认为false(如果不配置有可能会进入死循环)
SerializerFeature.DisableCircularReferenceDetect,
SerializerFeature.PrettyFormat
);
//在转换器中添加配置信息
fastConverter.setFastJsonConfig(fastJsonConfig);
List<MediaType> supportedMediaTypes = new ArrayList<>();
supportedMediaTypes.add(MediaType.APPLICATION_JSON);
supportedMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
fastConverter.setSupportedMediaTypes(supportedMediaTypes);
return fastConverter;
} }
} }
...@@ -72,7 +72,7 @@ public class OrderPayResponseDto { ...@@ -72,7 +72,7 @@ public class OrderPayResponseDto {
private String appid; private String appid;
@JSONField(name = "package") @JsonProperty("package")
private String packageX; private String packageX;
@JsonProperty("nonce_str") @JsonProperty("nonce_str")
......
...@@ -74,7 +74,7 @@ public class CombPayResponse { ...@@ -74,7 +74,7 @@ public class CombPayResponse {
*/ */
private String appId; private String appId;
@JSONField(name = "package") @JsonProperty("package")
private String packageX; private String packageX;
//@JsonProperty("nonce_str") //@JsonProperty("nonce_str")
......
...@@ -16,12 +16,12 @@ import org.springframework.context.annotation.Bean; ...@@ -16,12 +16,12 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
* WebMvcConfigurer * WebMvcConfigurer
*/ */
...@@ -45,35 +45,45 @@ public class WebMvcConfig implements WebMvcConfigurer { ...@@ -45,35 +45,45 @@ public class WebMvcConfig implements WebMvcConfigurer {
objectMapper.registerModule(simpleModule); objectMapper.registerModule(simpleModule);
return objectMapper; return objectMapper;
} }
// @Bean
// public HttpMessageConverter fastjsonHttpMessageConverter() {
// //定义一个转换消息的对象
// FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
//
// //添加fastjson的配置信息 比如 :是否要格式化返回的json数据
// FastJsonConfig fastJsonConfig = new FastJsonConfig();
//
// //过滤并修改配置返回内容
// fastJsonConfig.setSerializerFeatures(
// //List字段如果为null,输出为[],而非null
// //SerializerFeature.WriteNullListAsEmpty,
// //字符类型字段如果为null,输出为"",而非null
//// SerializerFeature.WriteNullStringAsEmpty,
// //Boolean字段如果为null,输出为false,而非null
//// SerializerFeature.WriteNullBooleanAsFalse,
// //SerializerFeature.WriteNullBooleanAsFalse,
// //消除对同一对象循环引用的问题,默认为false(如果不配置有可能会进入死循环)
// SerializerFeature.DisableCircularReferenceDetect,
// SerializerFeature.PrettyFormat
// );
//
// //在转换器中添加配置信息
// fastConverter.setFastJsonConfig(fastJsonConfig);
// List<MediaType> supportedMediaTypes = new ArrayList<>();
// supportedMediaTypes.add(MediaType.APPLICATION_JSON);
// supportedMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
// fastConverter.setSupportedMediaTypes(supportedMediaTypes);
// return fastConverter;
// }
@Bean @Bean
public HttpMessageConverter fastjsonHttpMessageConverter() { public MappingJackson2HttpMessageConverter getMappingJackson2HttpMessageConverter() {
//定义一个转换消息的对象 MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter();
FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter(); //设置中文编码格式
List<MediaType> list = new ArrayList<MediaType>();
//添加fastjson的配置信息 比如 :是否要格式化返回的json数据 list.add(MediaType.APPLICATION_JSON_UTF8);
FastJsonConfig fastJsonConfig = new FastJsonConfig(); mappingJackson2HttpMessageConverter.setSupportedMediaTypes(list);
return mappingJackson2HttpMessageConverter;
//过滤并修改配置返回内容
fastJsonConfig.setSerializerFeatures(
//List字段如果为null,输出为[],而非null
//SerializerFeature.WriteNullListAsEmpty,
//字符类型字段如果为null,输出为"",而非null
// SerializerFeature.WriteNullStringAsEmpty,
//Boolean字段如果为null,输出为false,而非null
// SerializerFeature.WriteNullBooleanAsFalse,
//SerializerFeature.WriteNullBooleanAsFalse,
//消除对同一对象循环引用的问题,默认为false(如果不配置有可能会进入死循环)
SerializerFeature.DisableCircularReferenceDetect,
SerializerFeature.PrettyFormat
);
//在转换器中添加配置信息
fastConverter.setFastJsonConfig(fastJsonConfig);
List<MediaType> supportedMediaTypes = new ArrayList<>();
supportedMediaTypes.add(MediaType.APPLICATION_JSON);
supportedMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
fastConverter.setSupportedMediaTypes(supportedMediaTypes);
return fastConverter;
} }
} }
...@@ -72,7 +72,7 @@ public class OrderPayResponseDto { ...@@ -72,7 +72,7 @@ public class OrderPayResponseDto {
private String appid; private String appid;
@JSONField( name = "package") @JsonProperty("package")
private String packageX; private String packageX;
@JsonProperty("nonce_str") @JsonProperty("nonce_str")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment