MvcConfig.java 801 B

1234567891011121314151617181920212223242526
  1. package com.yihu.jw.manage.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. * Created by chenweida on 2017/5/31.
  7. */
  8. @Configuration
  9. public class MvcConfig extends WebMvcConfigurerAdapter {
  10. /**
  11. * 支持跨域问题
  12. * 资料:http://blog.csdn.net/dalangzhonghangxing/article/details/51994812
  13. * @param registry
  14. */
  15. @Override
  16. public void addCorsMappings(CorsRegistry registry) {
  17. registry.addMapping("/**")
  18. .allowedOrigins("*")
  19. .allowCredentials(true)
  20. .allowedMethods("GET", "POST", "DELETE", "PUT")
  21. .maxAge(3600);
  22. }
  23. }