前后端数据交互出现json数据类型不符合
此种情况为前端与后端json格式不统一导致
1.json 分为两种类型;
(1) json 对象类型,即前端定义的Content type 为 application/x-www-form-urlencoded等
(2) json字符串类型,即前端定义的Content type 为 application/json
当前端定义为 application/x-www-form-urlencoded 时我们的接收如下
@ApiOperation(value = "提交试用申请", notes = "申请试用表单提交接口")
@ResponseBody
@RequestMapping(value = "/submitApply", method = RequestMethod.POST)
public Result applyFor(@RequestParam SubmitApplyVO submitApplyVO ){}
这里使用的参数接收注解是:@RequestParam 用来接收此类型的json参数正常。
当前段定义为 application/json 时我们的接收如下
@ApiOperation(value = "提交试用申请", notes = "申请试用表单提交接口")
@ResponseBody
@RequestMapping(value = "/submitApply", method = RequestMethod.POST)
public Result applyFor(@RequestBody SubmitApplyVO submitApplyVO){}
这里使用的参数接收注解是:@RequestBody 可以正常接收json。
更多推荐
Content type 'application/x-www-form-urlencoded;charset=UTF-8' not sup
发布评论