Springboot 写接口
前台传递数组 转换为JSON格式
JSON.stringify(data)
后台接口
@RequestBody 接收
需要使用
JSONObject jsonObject
来吧JSON数据转换成Array 数组格式
JSONArray jsonArray= jsonObject.getJSONArray(“JSON数据对象名称”);
如果报错
Resolved [org.springframework.web.HttpMediaTypeNotSupportedException: Content type ‘application/x-www-form-urlencoded;charset=UTF-8’ not supported]
原因为:
前台接口请求头需要修改为
‘Content-Type’:‘application/json;’,
如果使用’Content-Type’:‘application/x-www-form-urlencoded;’,则不行
【无标题】Resolved [org.springframework.web.HttpMediaTypeNotSupportedException: Content type ‘application
最新推荐文章于 2024-09-14 12:44:55 发布