|
|
|
@@ -13,6 +13,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties |
|
|
|
import org.springframework.boot.web.servlet.FilterRegistrationBean; |
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
import org.springframework.http.MediaType; |
|
|
|
import org.springframework.http.converter.HttpMessageConverter; |
|
|
|
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; |
|
|
|
import org.springframework.web.cors.CorsConfiguration; |
|
|
|
@@ -20,11 +21,14 @@ import org.springframework.web.cors.UrlBasedCorsConfigurationSource; |
|
|
|
import org.springframework.web.filter.CharacterEncodingFilter; |
|
|
|
import org.springframework.web.filter.CorsFilter; |
|
|
|
import org.springframework.web.servlet.config.annotation.*; |
|
|
|
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter; |
|
|
|
|
|
|
|
import javax.servlet.Filter; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.BigInteger; |
|
|
|
import java.nio.charset.Charset; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
@Configuration |
|
|
|
@@ -35,6 +39,27 @@ public class WebConfig implements WebMvcConfigurer { |
|
|
|
@Autowired |
|
|
|
private RequestInterceptor requestInterceptor; |
|
|
|
|
|
|
|
@Bean |
|
|
|
public RequestMappingHandlerAdapter requestMappingHandlerAdapter() { |
|
|
|
RequestMappingHandlerAdapter adapter = new RequestMappingHandlerAdapter(); |
|
|
|
|
|
|
|
List<HttpMessageConverter<?>> converters = adapter.getMessageConverters(); |
|
|
|
|
|
|
|
MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter(); |
|
|
|
List<MediaType> supportedMediaTypes = new ArrayList<MediaType>(); |
|
|
|
MediaType textMedia = new MediaType(MediaType.TEXT_PLAIN, Charset.forName("UTF-8")); |
|
|
|
supportedMediaTypes.add(textMedia); |
|
|
|
MediaType jsonMedia = new MediaType(MediaType.APPLICATION_JSON, Charset.forName("UTF-8")); |
|
|
|
supportedMediaTypes.add(jsonMedia);jsonConverter.setSupportedMediaTypes(supportedMediaTypes); |
|
|
|
|
|
|
|
converters.add(jsonConverter); |
|
|
|
|
|
|
|
|
|
|
|
adapter.setMessageConverters(converters); |
|
|
|
|
|
|
|
return adapter; |
|
|
|
} |
|
|
|
|
|
|
|
@Bean |
|
|
|
public CorsFilter corsFilter() { |
|
|
|
final UrlBasedCorsConfigurationSource urlBasedCorsConfigurationSource = new UrlBasedCorsConfigurationSource(); |
|
|
|
|