|
|
@ -1,10 +1,20 @@ |
|
|
|
package com.company.project.configurer; |
|
|
|
package com.company.project.configurer; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
|
|
|
import java.nio.charset.Charset; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
import java.util.Collections; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.ServletException; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.serializer.SerializerFeature; |
|
|
|
import com.alibaba.fastjson.serializer.SerializerFeature; |
|
|
|
import com.alibaba.fastjson.support.config.FastJsonConfig; |
|
|
|
import com.alibaba.fastjson.support.config.FastJsonConfig; |
|
|
|
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter4; |
|
|
|
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; |
|
|
|
|
|
|
|
|
|
|
|
import com.company.project.core.Result; |
|
|
|
import com.company.project.core.Result; |
|
|
|
import com.company.project.core.ResultCode; |
|
|
|
import com.company.project.core.ResultCode; |
|
|
|
import com.company.project.core.ServiceException; |
|
|
|
import com.company.project.core.ServiceException; |
|
|
@ -24,15 +34,6 @@ import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
|
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; |
|
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; |
|
|
|
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; |
|
|
|
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; |
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.ServletException; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
|
|
|
import java.nio.charset.Charset; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
import java.util.Collections; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Spring MVC 配置 |
|
|
|
* Spring MVC 配置 |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -46,7 +47,7 @@ public class WebMvcConfigurer extends WebMvcConfigurerAdapter { |
|
|
|
//使用阿里 FastJson 作为JSON MessageConverter
|
|
|
|
//使用阿里 FastJson 作为JSON MessageConverter
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { |
|
|
|
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { |
|
|
|
FastJsonHttpMessageConverter4 converter = new FastJsonHttpMessageConverter4(); |
|
|
|
FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter(); |
|
|
|
FastJsonConfig config = new FastJsonConfig(); |
|
|
|
FastJsonConfig config = new FastJsonConfig(); |
|
|
|
config.setSerializerFeatures(SerializerFeature.WriteMapNullValue,//保留空的字段
|
|
|
|
config.setSerializerFeatures(SerializerFeature.WriteMapNullValue,//保留空的字段
|
|
|
|
SerializerFeature.WriteNullStringAsEmpty,//String null -> ""
|
|
|
|
SerializerFeature.WriteNullStringAsEmpty,//String null -> ""
|
|
|
|