| | |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.http.converter.HttpMessageConverter; |
| | | import org.springframework.web.servlet.config.annotation.CorsRegistry; |
| | | import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; |
| | | |
| | | import java.nio.charset.StandardCharsets; |
| | |
| | | @Configuration |
| | | public class WebConfig extends WebMvcConfigurationSupport { |
| | | /** |
| | | * 跨域请求 |
| | | */ |
| | | @Override |
| | | protected void addCorsMappings(CorsRegistry registry) { |
| | | registry.addMapping("/**") |
| | | //.allowCredentials(true) |
| | | .allowedOrigins("*") |
| | | .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") |
| | | .allowedHeaders("*") |
| | | .maxAge(3600); |
| | | } |
| | | |
| | | /** |
| | | * 处理json格式,值null的转换为"" |
| | | */ |
| | | @Override |