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

相关内容

热门资讯

玩家必看科普!hhpoker辅... 玩家必看科普!hhpoker辅助挂是真的吗,wepoker有没有辅助(切实真的是有挂)hhpoker...
必备科技!约局吧德州透视,we... 必备科技!约局吧德州透视,wepokerplus辅助(其实是有挂)约局吧德州透视透视方法中分为三种模...
玩家攻略推荐!创思维激k看底牌... 玩家攻略推荐!创思维激k看底牌辅助(开挂辅助方法)都是有透视妙招1、这是跨平台的创思维激k看底牌辅助...
一分钟了解!约局吧辅助器,hh... 一分钟了解!约局吧辅助器,hh poker透视器下载(一直是有挂)进入游戏-大厅左侧-新手福利-激活...
最新技巧!决胜麻架胡易辅助(开... 最新技巧!决胜麻架胡易辅助(开挂辅助方法)其实有透视妙招暗藏猫腻,小编详细说明决胜麻架胡易辅助破解器...
重大通报!wepoker插件程... 重大通报!wepoker插件程序激活码,hhpoker真的有透视吗(本来存在有挂)1、每一步都需要思...
大神推荐!上品辅助器(总结辅助... 大神推荐!上品辅助器(总结辅助方法)原来有透视要领该软件可以轻松地帮助玩家将上品辅助器外卦神器提升到...
一起来探讨!wpk插件辅助,佛... 一起来探讨!wpk插件辅助,佛手大菠萝辅助(都是是有挂)1、实时佛手大菠萝辅助透视辅助更新:用户可以...
终于知道!德扑之星私人局辅助(... 终于知道!德扑之星私人局辅助(有挂辅助软件)一直有透视方式1、德扑之星私人局辅助破解器简单,德扑之星...
科技新动态!wepoker私人... 科技新动态!wepoker私人局怎么玩,wepoker免费钻石(其实有挂)运wepoker私人局怎么...