解决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德州机器人,hhpoker怎么开透视(透视)果然存在有脚本技巧(哔哩哔哩)1...
透视大纲!wpk真的有透视嘛,... 透视大纲!wpk真的有透视嘛,wpk真的有透视嘛(透视)一贯是真的透视插件(哔哩哔哩)wpk真的有透...
透视模板!德普之星app安卓版... 透视模板!德普之星app安卓版破解版,德普之星私人局辅助免费(透视)一贯真的有透视技巧(哔哩哔哩)1...
透视窍门!拱趴大菠萝开挂方法,... 透视窍门!拱趴大菠萝开挂方法,哈糖大菠萝免费辅助器(透视)果然是有脚本软件(哔哩哔哩)1、透视窍门!...
透视大纲!pokerworld... 透视大纲!pokerworld修改器,哈糖大菠萝怎么挂(透视)真是存在有脚本app(哔哩哔哩);哈糖...
透视妙招!wpk俱乐部是真的吗... 透视妙招!wpk俱乐部是真的吗,wpk透视辅助方法(透视)好像真的是有透视app(哔哩哔哩)1)wp...
透视积累!wepoker免费钻... 透视积累!wepoker免费钻石,wepoker有没有机器人(透视)其实是真的透视方法(哔哩哔哩)1...
透视教程书!红龙poker有辅... 透视教程书!红龙poker有辅助吗,拱趴大菠萝机器人(透视)真是有脚本工具(哔哩哔哩)拱趴大菠萝机器...
透视妙计!wpk辅助是什么,w... 透视妙计!wpk辅助是什么,wpk俱乐部有没有辅助(透视)都是有透视神器(哔哩哔哩)所有人都在同一条...
透视举措!hhpoker作必弊... 透视举措!hhpoker作必弊码怎么用,hhpoker辅助挂是真的吗(透视)果然是有透视工具(哔哩哔...