You've already forked FrameTour-BE
修整代码
This commit is contained in:
@@ -3,8 +3,7 @@ package com.ycwl.basic.config;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import com.ycwl.basic.interceptor.AuthInterceptor;
|
||||
import com.ycwl.basic.xss.XssJacksonDeserializer;
|
||||
import com.ycwl.basic.xss.XssJacksonSerializer;
|
||||
import com.ycwl.basic.stats.interceptor.StatsInterceptor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -29,13 +28,17 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
||||
|
||||
@Autowired
|
||||
private AuthInterceptor authInterceptor;
|
||||
@Autowired
|
||||
private StatsInterceptor statsInterceptor;
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(authInterceptor)
|
||||
// 拦截除指定接口外的所有请求,通过判断 注解 来决定是否需要做登录验证
|
||||
.addPathPatterns("/**")
|
||||
.excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/api-docs", "/doc.html/**", "/error", "/csrf", "/");
|
||||
.excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/api-docs", "/doc.html/**", "/error", "/");
|
||||
registry.addInterceptor(statsInterceptor)
|
||||
.addPathPatterns("/api/mobile/**");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,25 +81,6 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public WebMvcConfigurer createConvert() {
|
||||
return new WebMvcConfigurer() {
|
||||
@Override
|
||||
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
|
||||
Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
|
||||
ObjectMapper mapper = builder.build();
|
||||
/*注入自定义的序列化工具,将RequestBody的参数进行转译后传输*/
|
||||
SimpleModule simpleModule = new SimpleModule();
|
||||
// XSS序列化
|
||||
simpleModule.addSerializer(String.class, new XssJacksonSerializer());
|
||||
simpleModule.addDeserializer(String.class, new XssJacksonDeserializer());
|
||||
mapper.registerModule(simpleModule);
|
||||
converters.add(new MappingJackson2HttpMessageConverter(mapper));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@Autowired
|
||||
private StringHttpMessageConverter stringHttpMessageConverter;
|
||||
@Autowired
|
||||
|
Reference in New Issue
Block a user