解决Field error in object ‘user‘ on field ‘name‘: rejected value [Tom]问题
创始人
2024-12-27 09:10:14
0

问题描述

使用postman传递参数,报错400。
在这里插入图片描述

400 Bad Request错误的含义
400 Bad Request错误表示服务器无法理解客户端发送的请求,原因通常是由于客户端发送的请求存在问题。

完整的报错信息如下:

Resolved [org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errorsField error in object 'user' on field 'name': rejected value [Tom]; codes [typeMismatch.user.name,typeMismatch.name,typeMismatch.int,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [user.name,name]; arguments []; default message [name]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'int' for property 'name'; nested exception is java.lang.NumberFormatException: For input string: "Tom"]] 

问题分析

报错400说明客户端传递参数无法正确被服务器接收,报错的重点:

  1. rejected value [Tom]; codes [typeMismatch.user.name,typeMismatch.name,typeMismatch.int,typeMismatch]
  2. Failed to convert property value of type ‘java.lang.String’ to required type ‘int’ for property ‘name’

类型不匹配,name要求int类型,服务器不会认为是自己设置有问题,会判定是客户端传递参数有问题。
回到idea找到代码,果然是int类型。

private int name; 

int 类型是idea联想后直接tab生成出来的,解决方式就是把name换成String类型,重新生成getter和setter,问题解决。

相关内容

热门资讯

针对!wepoker有什么规律... 针对!wepoker有什么规律,WePoKer辅助器(透视)秘籍教程(其实是有挂)亲,关键说明,we...
有了最新消息!陕西三代二辅助器... 有了最新消息!陕西三代二辅助器,微信小程序微乐辅助器贴吧,大纲教程(有挂方法)-哔哩哔哩运微信小程序...
透视分享!sohoo poke... 透视分享!sohoo poker辅助(透视)wpk插件辅助,教程积累(有挂详情)-哔哩哔哩1、许多玩...
透视透视!三哥玩辅助,微乐小程... 透视透视!三哥玩辅助,微乐小程序脚本(开挂)都是真的是有挂(有挂解密)-哔哩哔哩1、微乐小程序脚本免...
有玩家发现!wepoker游戏... 有玩家发现!wepoker游戏下载,wepoker辅助分析器(透视)模块教程(原来是有挂)1、上手简...
这一现象值得深思!蜀山四川小程... 这一现象值得深思!蜀山四川小程序辅助开挂,德普之星的辅助工具介绍,指引教程(有挂辅助)-哔哩哔哩1、...
透视总结!hhpoker透视码... 透视总结!hhpoker透视码怎么用(透视)约局吧开挂,教程手筋(有挂猫腻)-哔哩哔哩1)hhpok...
透视苹果版!微乐透视辅助工具,... 透视苹果版!微乐透视辅助工具,雀姬辅助工具(开挂)本来真的有挂(有挂透视)-哔哩哔哩1、微乐透视辅助...
针对!德普之星辅助工具如何设置... 针对!德普之星辅助工具如何设置,wepoker辅助器(透视)方案教程(果然真的是有挂)1、德普之星辅...
这一问题亟待解决!佛手在线是不... 这一问题亟待解决!佛手在线是不是有挂,微乐辅助靠谱麻,诀窍教程(有挂总结)-哔哩哔哩1、玩家可以在佛...