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

相关内容

热门资讯

据统计!开心泉州免费辅助器!竟... 据统计!开心泉州免费辅助器!竟然存在有辅助神器(有挂详细)-哔哩哔哩1、玩家可以在开心泉州免费辅助器...
重大科普!wepoker轻量版... 重大科普!wepoker轻量版有透视吗,约局吧德州透视,开挂教程(有挂透视)-哔哩哔哩1、wepok...
有玩家发现!逗娱碰胡辅助器!确... 有玩家发现!逗娱碰胡辅助器!确实是有辅助安装(确实有挂)-哔哩哔哩逗娱碰胡辅助器透视方法中分为三种模...
来一盘!wpk透视怎么安装,h... 来一盘!wpk透视怎么安装,hhpoker的辅助是真的吗,详细教程(有挂功能)-哔哩哔哩1、全新机制...
现有说明如下!丽水茶苑辅助平台... 现有说明如下!丽水茶苑辅助平台购买!切实真的是有辅助脚本(有人有挂)-哔哩哔哩1、丽水茶苑辅助平台购...
六分钟了解!poker wor... 六分钟了解!poker world辅助器,hhpoker透视脚本,曝光教程(有挂技巧)-哔哩哔哩1、...
近日!wepoker破解版内购... 近日!wepoker破解版内购!其实有挂辅助工具(有挂方法)-哔哩哔哩1、wepoker破解版内购破...
重大通报!hhpoker哪个俱... 重大通报!hhpoker哪个俱乐部靠谱,hhpoker软件靠谱吗,分享教程(有挂透明挂)-哔哩哔哩1...
此事引发广泛关注!传送屋辅助器... 此事引发广泛关注!传送屋辅助器!总是真的是有辅助脚本(有挂教程)-哔哩哔哩传送屋辅助器辅助器是一种具...
每日必看!wejoker手机版... 每日必看!wejoker手机版透视脚本,hhpoker透视方法,详情教程(有挂分享)-哔哩哔哩该软件...