Tag - CORS

Shiro Java CORS 跨域    2019-02-20 22:46:57    7    0    0

shiro前后分离跨域预检不带cookies处理办法

解决参考网站地址:

前端配置:

  1. //(必备)此配置允许跨域请求带上Cookie
  2. withCredentials: true

后台配置:

第一步: web.xml Filter过滤器调整顺序: CORSFilter在shiroFilter 之前

  1. <!--解决跨域访问 -->
  2. <filter>
  3. <filter-name>crossorigin</filter-name>
  4. <filter-class>com.woke.util.CORSFilter</filter-class>
  5. </filter>
  6. <filter-mapping>
  7. <filter-name>crossorigin</filter-name>
  8. <url-pattern>/*</url-pattern>
  9. </filter-mapping>
  10. <!-- 配置shiro过滤器 -->
  11. <filter>
  12. <filter-name>shiroFilter</filter-name>
  13. <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
  14. <init-param>
  15. <param-name>targetFilterLifecycle</param-name>
  16. <param-value>true</param-value>
  17. </init-param>
  18. <init-param>
  19. <param-name>targetBeanName</param-name>
  20. <param-value>shiroFilter</param-value>
  21. </init-param>
  22. </filter>
  23. <filter-mapping>
  24. <filt