| 123456789101112131415161718192021222324252627282930313233 |
- package com.pub.config;
- import org.springframework.context.annotation.Bean;
- import org.springframework.context.annotation.Configuration;
- import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
- import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
- import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
- import com.fasterxml.jackson.databind.DeserializationFeature;
- import com.fasterxml.jackson.databind.ObjectMapper;
- import com.pub.interceptor.CustomInterceptor;
- @Configuration
- public class CustomInterceptorConfig implements WebMvcConfigurer {
- @Override
- public void addInterceptors(InterceptorRegistry registry) {
- registry.addInterceptor(new CustomInterceptor()).addPathPatterns("/**").excludePathPatterns("/s/**",
- "/framework-ui/**","/ws/**", "/error/**", "/index/login", "/index/initData","/fileUpload/upload");
- }
- @Bean
- public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() {
- MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
- ObjectMapper objectMapper = new ObjectMapper();
- // 添加此配置
- objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- converter.setObjectMapper(objectMapper);
- return converter;
- }
- }
|