一.跨域请求
1.域
域:协议+IP+端口
2.Ajax跨域问题
3.方案
- 允许其他域访问
- 在被访问方的Controller类上,添加注解
@CrossOrigin("http://localhost:8080") //允许此域发请求访问
public class SysUserController {
....
}
$.ajax({
type: "POST",
url: "http://localhost:8989/web/sys/login",
...,
xhrFields: {
// 跨域携带cookie
withCredentials: true
}
});
或
var xhr = new XMLHttpRequest();
// 跨域携带cookie
xhr.withCredentials=true;
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。