您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

37 行
1.2 KiB

  1. package com.ffii.tsms.config;
  2. import org.springframework.context.annotation.Bean;
  3. import org.springframework.context.annotation.Configuration;
  4. import org.springframework.http.MediaType;
  5. import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
  6. import org.springframework.web.servlet.config.annotation.CorsRegistry;
  7. import org.springframework.web.servlet.config.annotation.EnableWebMvc;
  8. import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
  9. import org.springframework.web.servlet.view.InternalResourceViewResolver;
  10. @Configuration
  11. @EnableWebMvc
  12. public class WebConfig implements WebMvcConfigurer {
  13. @Override
  14. public void addCorsMappings(CorsRegistry registry) {
  15. registry.addMapping("/**")
  16. .allowedHeaders("*")
  17. .allowedOrigins("*")
  18. .exposedHeaders("Content-Disposition")
  19. .allowedMethods("GET", "POST", "PUT", "DELETE", "HEAD");
  20. }
  21. @Bean
  22. public InternalResourceViewResolver defaultViewResolver() {
  23. return new InternalResourceViewResolver();
  24. }
  25. @Override
  26. public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
  27. configurer.defaultContentType(MediaType.APPLICATION_JSON);
  28. }
  29. }