标签:chain -o eth utf-8 override des domain origin https
public class CrossDomainFilter implements Filter { @Override public void init(FilterConfig filterConfig) throws ServletException { // TODO Auto-generated method stub } @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletResponse resp = (HttpServletResponse) response; // 允许跨域ajax请求 resp.setHeader("Access-Control-Allow-Origin", "*"); resp.setHeader("Access-Control-Allow-Methods", "*"); resp.setHeader("Access-Control-Allow-Headers", "accept, origin, content-type"); resp.setHeader("Content-Type", "application/json;charset=UTF-8"); chain.doFilter(request, resp); } @Override public void destroy() { // TODO Auto-generated method stub } }
标签:chain -o eth utf-8 override des domain origin https
原文地址:http://www.cnblogs.com/programmer1/p/7994045.html