Vue中axios访问 后端跨域问题
public class AllowOriginFilter implements Filter { @SuppressWarnings("unused") public void doFileter(ServletRequest req,ServletResponse res,FilterChain chain) throws IOException,ServletException{ HttpServletResponse response = (HttpServletResponse) res; HttpServletRequest request=(HttpServletRequest)req; response.setHeader("Access-Control-Allow-Origin", "*"); // 设置允许所有跨域访问 response.setHeader("Access-Control-Allow-Methods", "POST,GET,PUT,OPTIONS,DELETE"); response.setHeader("Access-Control-Max-Age", "3600"); response.setHeader("Access-Control-Allow-Headers", "Origin,X-Requested-With,Content-Type,Accept,Authorization,token"); response.setHeader("Access-Control-Allow-Credentials", "true"); chain.doFilter(req,res); } public void init(FilterConfig filterConfig) {} public void destroy() {} }