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

相关内容

热门资讯

wpk辅助工具!wepoker... 自定义德普之星透视辅助ios系统规律,只需要输入自己想要的开挂功能,一键便可以生成出微扑克专用辅助器...
透视能赢“wepoker底牌透... 透视能赢“wepoker底牌透视脚本”其实是真的有挂(辅助挂)详细辅助2025新版技巧暗藏猫腻,小编...
透视代打!红龙poker透视,... 透视代打!红龙poker透视,悦扑克脚本(详细辅助可靠教程);悦扑克脚本软件透明挂作为一款悦扑克脚本...
透视app!werplan外挂... 透视app!werplan外挂,欢乐联盟免费辅助(都是真的有挂)1、完成欢乐联盟免费辅助透视辅助安装...
wepoker底牌透视脚本ht... wepoker底牌透视脚本http!拱趴大菠萝挂哪里,aapoker俱乐部靠谱吗(详细辅助透明挂教程...
透视肯定“hhpoker辅助器... 透视肯定“hhpoker辅助器”都是真的有挂(辅助挂)详细辅助透明挂教程辅助器中分为三种模型:软件透...
透视辅助!德普之星辅助器,we... 透视辅助!德普之星辅助器,wepoker私人局俱乐部辅助(详细辅助黑科技教程);支持2-10人实时对...
透视好牌!wepoker辅助是... 透视好牌!wepoker辅助是真的吗,洞庭茶苑app辅助(切实是真的有挂);1、操作简单,无需注册,...
aapoker透视插件!wep... aapoker透视插件!wepoker私人局辅助器怎么用,hhpoker透视方法(详细辅助科技教程)...
透视ai“德普之星透视辅助io... 透视ai“德普之星透视辅助ios”总是有挂(辅助挂)详细辅助揭秘教程1、透视ai“德普之星透视辅助i...