首页 > 技术文章 > spring 2 jackson datefomat失效的问题解决

zkj1204 2021-06-11 18:06 原文

1.有的同学是继承:WebMvcConfigurationSupport 

 

原因分析:
拦截器继承的 WebMvcConfigurationSupport !
以前是用 WebMvcConfigurerAdapter ,springboot 2.0 建议使用 WebMvcConfigurationSupport 。但是在添加拦截器并继承WebMvcConfigurationSupport后会覆盖@EnableAutoConfiguration关于WebMvcAutoConfiguration的配置!从而导致所有的Date`返回都变成时间戳!
解决方法:
实现 WebMvcConfigurer。
将:extends WebMvcConfigurationSupport 改为:implements WebMvcConfigurer
————————————————
版权声明:本文为CSDN博主「陈永佳」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/Mrs_chens/article/details/103352990

 

 

2.有@EnableWebMvc

去掉这个注解就行了。

 

具体没研究。。

推荐阅读