ueditor.all.js?29c8:23838 OPTIONS http://starskybbs.ngrok.cc/starskybbs/ueditor/jsp/controller.jsp? sendAndInsertFile @ ueditor.all.js?29c8:23838(anonymous function) @ ueditor.all.js?29c8:23878
VM5253 8780236…:1 XMLHttpRequest cannot load http://starskybbs.ngrok.cc/starskybbs/ueditor/jsp/controller.jsp?. Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed. Origin 'http://172.16.28.4:8080' is therefore not allowed access.
ueditor.all.js?29c8:23838 XHR failed loading: POST "http://starskybbs.ngrok.cc/starskybbs/ueditor/jsp/controller.jsp?".sendAndInsertFile @ ueditor.all.js?29c8:23838(anonymous function) @ ueditor.all.js?29c8:23878
11 回复
public class CorsFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
ServletException {
// TODO Auto-generated method stub
HttpServletResponse res = (HttpServletResponse) response;
res.setContentType("text/html;charset=UTF-8");
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
res.setHeader("Access-Control-Max-Age", "0");
res.setHeader("Access-Control-Allow-Headers", "Origin, No-Cache, X-Requested-With, If-Modified-Since, Pragma, Last-Modified, Cache-Control, Expires, Content-Type, X-E4M-With,userId,token");
res.setHeader("Access-Control-Allow-Credentials", "true");
res.setHeader("XDomainRequestAllowed","1");
chain.doFilter(request, response);
chain.doFilter(request, response);
}
@Override
public void destroy() {
}
}
写了自己的过滤器,这样过滤可以实现吗?
添加回复
请先登陆