前后端跨域出现Cross-Origin Read Blocking (CORB) blocked cross-origin报错

kingofdancer 2019-08-24 12:17:53
Cross-Origin Read Blocking (CORB) blocked cross-origin response http://www.xxx.net.cn:24058/hnlz-archivesz/ with MIME type text/html. See https://www.chromestatus.com/feature/5629709824032768 for more details.
一直报这个错 我都不知道是我前端ajax问题还是后端接口问题 代码我全贴 希望大佬帮我解决 蟹蟹
前端ajax请求:
layui.$.ajax({
beforeSend: function (request) {
request.setRequestHeader("Accept",'application/json');
//request.setRequestHeader("Access-Control-Allow-Methods:POST,GET");
request.setRequestHeader('Content-Type', 'application/json');
},
url: 'http://www.xxx.net.cn:30334/ArchiveHNBackend/person/platform',//这里是地址
type: "get",
dataType: "jsonp",//跨域
crossDomain: true,
//contentType: "application/x-www-form-urlencoded; charset=utf-8",
//jsonp: "callback",
data: { "name": data.PersonName },
success: function (data) {
console.log(data);
}
});



后台接口代码

    @RequestMapping("/platform")
public void platformList(@RequestParam String name,HttpServletRequest request,HttpServletResponse response){
/*PageHelper.startPage(1, 100);
List<Person> list = personService.platformList(name);
PageInfo pageInfo = new PageInfo(list);
return ResultGenerator.genSuccessResult(pageInfo);*/
String token ="";
Users users = null;
users = usersService.findByUserName(UNAME);
long time = System.currentTimeMillis();
String subject = users.getUsername() + ","
+ users.getRealname() + ","
+ users.getRoleid() + ","
+ users.getId() + ","
+ users.getDeptid();
token = Jwts.builder()
.setSubject(subject)
// 设置过期时间 1 * 24 * 60 * 60秒情况修改)
.setExpiration(new Date(time + JwtConfig.Time))
//采用什么算法是可以自己选择的,不一定非要采用HS512
.signWith(SignatureAlgorithm.HS512, JwtConfig.SIGNING_KEY)
.compact();//压缩成XXXX.XXX格式
UserDto u = new UserDto();
u.setToken(token);
try {
redis.setStr(users.getUsername(), token);
} catch (Exception e) {
e.printStackTrace();
}
//log.info("用户" + users.getUsername() + "成功登陆");
try {
response.sendRedirect(URL + "token=" + token + "&code=" + 200 + "&homepage=Dashboard" + "&condition="+name);
response.setHeader("Access-Control-Allow-Origin", "http://localhost:6223");
response.setHeader("Access-Control-Allow-Credentials", "true");
//解决跨域
//getJsonpData(request,response);
System.out.println(response);
} catch (IOException e) {
e.printStackTrace();
}
}
...全文
16611 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
  2021-03-30
  • 打赏
  • 举报
回复
大哥解决了吗 遇过同样的问题 前端不是我的改不了 只能改后台
荔枝师 2021-08-31
  • 举报
回复
@  您好请问解决了吗
  • 打赏
  • 举报
回复
有一个跨域注解 加在controller层 好像是@Crs啥来着 百度下就知道了
weixin_43127434 2020-09-04
  • 打赏
  • 举报
回复
我也是这个问题,不会
荔枝师 2021-08-31
  • 举报
回复
@weixin_43127434 您好请问解决了吗
kingofdancer 2019-08-24
  • 打赏
  • 举报
回复
有没有大哥啊帮忙啊 心累啊
荔枝师 2021-08-31
  • 举报
回复
@kingofdancer 您好请问解决了吗
faith.huan 2019-08-24
  • 打赏
  • 举报
回复
在后台方法上加上 @CrossOrigin注解试一下


import org.springframework.web.bind.annotation.CrossOrigin;
 @CrossOrigin
 @RequestMapping("/platform")
    public void platformList(@RequestParam String name,HttpServletRequest request,HttpServletResponse response){
        /*PageHelper.startPage(1, 100);
        List<Person> list = personService.platformList(name);
        PageInfo pageInfo = new PageInfo(list);
        return ResultGenerator.genSuccessResult(pageInfo);*/
        String token ="";

50,528

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧