接收企微事件回调 Content type ‘text/xml;charset=UTF-8’ not supported
@Log4j2 @Configuration public class WebConfig extends WebMvcConfigurationSupport { @Override public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { super.configureMessageConverters(converters); //支持XML List<MediaType> xmlMediaTypes = new ArrayList<>(); xmlMediaTypes.add(MediaType.TEXT_XML); StringHttpMessageConverter xmlMessageConverter = new StringHttpMessageConverter(); xmlMessageConverter.setSupportedMediaTypes(xmlMediaTypes); converters.add(xmlMessageConverter); //JSON FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter(); FastJsonConfig fastJsonConfig = new FastJsonConfig(); fastJsonConfig.setSerializerFeatures( SerializerFeature.PrettyFormat, //int类型的key 加引号 SerializerFeature.WriteNonStringKeyAsString, //保留map空的字段 SerializerFeature.WriteMapNullValue, //将Number类型的null转成0 SerializerFeature.WriteNullNumberAsZero, // 将List类型的null转成[] SerializerFeature.WriteNullListAsEmpty, // 将Boolean类型的null转成false SerializerFeature.WriteNullBooleanAsFalse); fastJsonConfig.setDateFormat("yyyy-MM-dd HH:mm:ss"); //处理中文乱码问题 List<MediaType> fastMediaTypes = new ArrayList<>(); fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8); fastConverter.setSupportedMediaTypes(fastMediaTypes); fastConverter.setFastJsonConfig(fastJsonConfig); converters.add(fastConverter); } }
============ 欢迎各位老板打赏~ ===========
与本文相关的文章
- · 调用企微接口报403 API Forbiden 无权限 的错误
- · Java基础问题13个,你都会哪些?
- · 不重新打包项目并替换部分jar包
- · springboot使用lock4j实现并发控制
- · springboot全局增加sentinel
- · linux快速搭建轻量级efk日志系统
- · Springboot整合Swagger常用注解
- · swagger隐藏authentication参数
- · Spring Security 中的自定义PreAuthorize 注解
- · Expected one result (or null) to be returned by selectOne(), but found: 2
- · JACKSON和FASTJSON处理返回JSON数据中为NULL字段不显示
- · mybatis报错 : Caused by: java.lang.IllegalStateException: Can not find owner from table.