springboot 项目中_ 利用Filter去解决跨域问题
springboot 项目中_ 利用Filter去解决跨域问题
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException { response.addHeader("Access-Control-Allow-Origin","*"); // response.addHeader("Access-Control-Allow-Methods","GET, POST, PUT, DELETE"); response.addHeader("Access-Control-Allow-Methods","*"); response.addHeader("Access-Control-Allow-Headers","Origin, Content-Type, Cookie, Accept, multipart/form-data, application/json"); response.addHeader("Access-Control-Expose-Headers", "Authorization"); response.addHeader("Access-Control-Max-Age","1800"); chain.doFilter(request, response); }