@H_
403_7@@Con
figuration
public class WarnWebMvcCon
figurationSupport extends WebMvcCon
figurationSupport
{
/
**
* @Author AlanMa
* @Description 全局fastJson替换
* @Param [converters]
* @return void
*/
@Override
public void con
figure
messageConverters(List<
httpmessageConverter<?>> converters)
{
super.con
figure
messageConverters(converters
);
FastJson
httpmessageConverter fastConverter = new FastJson
httpmessageConverter(
);
FastJsonCon
fig fastJsonCon
fig = new FastJsonCon
fig(
);
fastJsonCon
fig.set
serializerFeatures(
serializerFeature.PrettyFormat,
serializerFeature.WriteNullListAsEmpty,
serializerFeature.WriteMapNullValue,
serializerFeature.WriteEnumUsingTo
String,
serializerFeature.WriteNull
StringAsEmpty
);
fastJsonCon
fig.setDateFormat("yyyy-MM-dd HH:mm:ss"
);
List<MediaType> fastMediaTypes = new ArrayList<>(
);
fastMediaType
s.add(MediaType.APPLICATION_JSON_UTF8
);
fastConverter.setSupportedMediaTypes(fastMediaTypes
);
fastConverter.setFastJsonCon
fig(fastJsonCon
fig);
converter
s.add(fastConverter
);
}
@Override
public void addCor
smappings(CorsRegistry registry)
{
registry.addMapping("/
**")
.allowedOrigins("*")
.allowedMethods("POST","GET","PUT","OPTIONS","
deletE")
.maxAge(3600)
.allowCredentials
(true);
}
}