解决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,问题解决。

相关内容

热门资讯

透视手段!哈糖大菠萝挂法,红龙... 透视手段!哈糖大菠萝挂法,红龙poker辅助平台(透视)真是真的是有脚本软件(哔哩哔哩)1、玩家可以...
透视策略!aapoker辅助工... 透视策略!aapoker辅助工具安全吗,aapoker真的假的(透视)真是存在有透视脚本(哔哩哔哩)...
透视攻略!hardrock透视... 透视攻略!hardrock透视工具,来玩app破解(透视)果然有透视教程(哔哩哔哩)暗藏猫腻,小编详...
透视办法!德普之星透视辅助插件... 透视办法!德普之星透视辅助插件,德扑圈透视(透视)竟然存在有透视技巧(哔哩哔哩)1、在德普之星透视辅...
透视课程!pokemmo辅助器... 透视课程!pokemmo辅助器,智星菠萝可以辅助吗(透视)原来真的是有脚本神器(哔哩哔哩)1、实时智...
透视妙计!cloudpoker... 透视妙计!cloudpoker外开挂,xpoker透视辅助(透视)一贯真的有透视工具(哔哩哔哩)1、...
透视讲义!aapoker破解侠... 透视讲义!aapoker破解侠是真的吗,aapoker发牌逻辑(透视)其实是真的透视神器(哔哩哔哩)...
透视学习!hhpoker破解工... 透视学习!hhpoker破解工具,hhpoker辅助器视频(透视)都是有脚本工具(哔哩哔哩)1、该软...
透视演示!sohoo poke... 透视演示!sohoo poker辅助器,德州局透视(透视)一直是有透视方法(哔哩哔哩)1、上手简单,...
透视练习!智星德州可以透视吗,... 透视练习!智星德州可以透视吗,sohoo poker辅助(透视)竟然是有透视教程(哔哩哔哩)智星德州...