我用html搞通过cros实现跨域访问但是session不能被跨域
来源:7-6 部门列表树型结构界面开发

慕粉3884565
2019-01-01
@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
//设置跨域请求
HttpServletResponse response = (HttpServletResponse) res;
//此处ip地址为需要访问服务器的ip及端口号
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Access-Control-Allow-Methods", "GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS, PATCH");
response.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type,Token,Accept, Connection, User-Agent, Cookie");
response.setHeader("Access-Control-Max-Age", "3628800");
chain.doFilter(req, response);
}
这是过滤器还要做哪些百度了他说是这么搞的
1回答
-
Jimin
2019-01-01
你好,你的cros代码看着没什么问题,怀疑是哪里你没使用对,另外你那两个依赖包我不知道是啥意思,没见过,不知道你想表达什么
022019-01-01
相似问题