| | |
| | | import javax.annotation.Resource; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.core.Ordered; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.http.converter.HttpMessageConverter; |
| | | import org.springframework.util.AntPathMatcher; |
| | | import org.springframework.web.servlet.config.annotation.*; |
| | | |
| | | import java.nio.charset.Charset; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | protected void addResourceHandlers(ResourceHandlerRegistry registry) { |
| | | registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); |
| | | registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/"); |
| | | registry.addResourceHandler("/druid/**").addResourceLocations("classpath:/META-INF/resources/druid/"); |
| | | registry.addResourceHandler("/**").addResourceLocations("classpath:/static/"); |
| | | super.addResourceHandlers(registry); |
| | | } |
| | |
| | | /** |
| | | * 跨域请求 |
| | | */ |
| | | @Override |
| | | /*@Override |
| | | protected void addCorsMappings(CorsRegistry registry) { |
| | | registry.addMapping("/**") |
| | | .allowCredentials(true) |
| | |
| | | .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") |
| | | .allowedHeaders("*") |
| | | .maxAge(3600); |
| | | } |
| | | }*/ |
| | | |
| | | /** |
| | | * 添加统一的拦截器 |
| | |
| | | //SerializerFeature.PrettyFormat); |
| | | |
| | | converter.setFastJsonConfig(config); |
| | | converter.setDefaultCharset(Charset.forName("UTF-8")); |
| | | converter.setDefaultCharset(StandardCharsets.UTF_8); |
| | | converter.setSupportedMediaTypes(Collections.singletonList( |
| | | MediaType.APPLICATION_JSON |
| | | )); |
| | | converters.add(converter); |
| | | } |
| | | } |