WebMvcConfig.java 699 B

1234567891011121314151617181920212223
  1. package com.happy.config;
  2. import org.springframework.context.annotation.Configuration;
  3. import org.springframework.web.servlet.config.annotation.CorsRegistry;
  4. import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
  5. /**
  6. * @author yp
  7. * @date 2020/2/23
  8. * 解决跨域问题
  9. */
  10. @Configuration
  11. public class WebMvcConfig extends WebMvcConfigurerAdapter {
  12. @Override
  13. public void addCorsMappings(CorsRegistry registry) {
  14. registry.addMapping("/**")
  15. .allowedOrigins("*")
  16. .allowedMethods("POST", "GET", "PUT", "OPTIONS", "DELETE")
  17. .maxAge(3600)
  18. .allowCredentials(true);
  19. }
  20. }