Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported

编程知识 更新时间:2023-04-05 06:50:33

前后端数据交互出现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

本文发布于:2023-04-05 06:50:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/d9174982ec68507d5a070d64dada1692.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:application   www   Content   type   form

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 45378文章数
  • 14阅读数
  • 0评论数