zoukankan      html  css  js  c++  java
  • SpringBoot 拦截器WebMvcConfigurationSupport导致date-format时间格式失效

    1、继承WebMvcConfigurationSupport实现自定义拦截器后,原先配置的时间格式返回变成时间戳,以下配置失效:

    spring
      jackson:
        date-format: yyyy-MM-dd HH:mm:ss
        time-zone: GMT+8

    2、解决办法不继承WebMvcConfigurationSupport,修改为实现WebMvcConfigurer接口

    @Configuration
    public class WebConfig implements WebMvcConfigurer {
    
        @Resource
        private JwtInterceptor jwtInterceptor;
    
        @Override
        public void addInterceptors(InterceptorRegistry registry) {
    
            registry.addInterceptor(jwtInterceptor)
                    //拦截所有url
                    .addPathPatterns("/**")
                    //排除登录url
                    .excludePathPatterns("/", "/login");
    
        }
    }

    3、另外还有方式就是引入fastjson替换jackson。

  • 相关阅读:
    X
    W
    J
    A
    Q
    P
    B
    排列和组合的求解
    深度学习之序列处理
    32位和64位数据类型大小对比
  • 原文地址:https://www.cnblogs.com/asker009/p/12752716.html
Copyright © 2011-2022 走看看