加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Ajax访问controller获取返回数据

发布时间:2020-12-16 03:37:04 所属栏目:百科 来源:网络整理
导读:当我们刚搭好框架准备用ajax调用controller层返回json数据时出现如下错误: 1.页面错误 The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers

当我们刚搭好框架准备用ajax调用controller层返回json数据时出现如下错误:

1.页面错误

The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers ()

2.浏览器控制台错误

No 'Access-Control-Allow-Origin' header is present on the requested resource.

原因在于你访问controller层,将返回给浏览器一些数据,而这些数据将以何种格式返回?你没有定义或者设置,该怎么办???

解决办法:
需要在配置文件里设置数据接收格式如下图:

设置之后页面可以直接返回结果:

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读