首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >HTTP Error 400 Bad request 的问题分析解决

HTTP Error 400 Bad request 的问题分析解决

作者头像
挑战者
发布于 2019-01-02 05:08:22
发布于 2019-01-02 05:08:22
5.4K00
代码可运行
举报
文章被收录于专栏:java沉淀java沉淀
运行总次数:0
代码可运行

问题描述:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
 前端保存老是报错HTTP ERROR 400 Bad Request。经过异常分析得出是前端传参导致的后端框架的验证拦截,包的错误。

异常信息如下:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
{"timestamp":1545873831082,"status":400,"error":"Bad Request","exception":"org.springframework.validation.BindException","errors":[{"codes":["typeMismatch.capitalInvestmentParam.investmentEnsureMoney","typeMismatch.investmentEnsureMoney","typeMismatch.java.math.BigDecimal","typeMismatch"],"arguments":[{"codes":["capitalInvestmentParam.investmentEnsureMoney","investmentEnsureMoney"],"arguments":null,"defaultMessage":"investmentEnsureMoney","code":"investmentEnsureMoney"}],"defaultMessage":"Failed to convert property value of type 'java.lang.String' to required type 'java.math.BigDecimal' for property 'investmentEnsureMoney'; nested exception is java.lang.NumberFormatException","objectName":"capitalInvestmentParam","field":"investmentEnsureMoney","rejectedValue":"null","bindingFailure":true,"code":"typeMismatch"},{"codes":["typeMismatch.capitalInvestmentParam.investmentEnsureMoneyInterest","typeMismatch.investmentEnsureMoneyInterest","typeMismatch.java.math.BigDecimal","typeMismatch"],"arguments":[{"codes":["capitalInvestmentParam.investmentEnsureMoneyInterest","investmentEnsureMoneyInterest"],"arguments":null,"defaultMessage":"investmentEnsureMoneyInterest","code":"investmentEnsureMoneyInterest"}],"defaultMessage":"Failed to convert property value of type 'java.lang.String' to required type 'java.math.BigDecimal' for property 'investmentEnsureMoneyInterest'; nested exception is java.lang.NumberFormatException","objectName":"capitalInvestmentParam","field":"investmentEnsureMoneyInterest","rejectedValue":"null","bindingFailure":true,"code":"typeMismatch"}],"message":"Validation failed for object='capitalInvestmentParam'. Error count: 2","path":"/rayProjectCapitalInvestment/insertStockPowerInvestment"}

分析异常信息:

Failed to convert property value of type 'java.lang.String' to required type 'java.math.BigDecimal' for property 'investmentEnsureMoneyInterest'; nested exception is java.lang.NumberFormatException

看一下前端传入的参数如下图:

image.png

image.png

经过分析得出400错误code:数据框架的验证拦截前端传入的参数异常。

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2018.12.27 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
补习系列-springboot 参数校验详解
在定义 Restful 风格的接口时,通常会采用 PathVariable 指定关键业务参数,如下:
美码师
2018/08/27
2.7K0
后端对前台传递的日期类型处理的两种方式
大家平时可能接触到前台传到后台的日期类型,那么大家是如何处理的呢?我先说说我之前是怎么处理的吧!
一个程序员的成长
2020/11/25
4.4K0
搭建SpringBoot项目问题汇总
大概意思是:日期在转换时 格式错误 String类型无法转换成Util.Date类型
啵啵鱼
2022/11/23
3.5K0
搭建SpringBoot项目问题汇总
There was an unexpected error (type=Bad Request, status=400). Failed to convert value of type ‘java.
@RequestParam(name = “userId”, required = false, defaultValue = " ") userId: Int
猫头虎
2024/04/08
2320
【快学springboot】5.全局异常捕获,异常流处理业务逻辑
上一篇文章说到,参数校验,往往需要和全局的异常拦截器来配套使用,使得返回的数据结构永远是保持一致的。参数异常springboot默认的返回结构:
Happyjava
2019/07/16
1.1K0
【快学springboot】5.全局异常捕获,异常流处理业务逻辑
Spring数据绑定之DataBinder篇---01
数据绑定对于一个成熟的Web框架而言十分的重要,通过将Http中的请求参数或者请求体中的Json字符串绑定到对应实体对象上,可以大大提高开发人员的效率。
大忽悠爱学习
2022/08/23
9190
Spring数据绑定之DataBinder篇---01
Spring boot的异常处理
而我们一个前后端分离的架构,我们写的Restful API往往会被多个渠道访问,比如浏览器,app。而我们的spring boo会根据不同的渠道做出不同的响应,是浏览器发的就返回html,不是则是json。若报错回跳转到/error的URL,同一个URL不同的处理方式是由Spring boot提供的BasicErrorController错误控制器实现的。
用户7386338
2020/05/29
1.3K0
The server encountered an internal error that prevented it from fulfilling this request的一种解决办法[通俗易懂]
这是我在编写服务器响应判断用户数据时遇到的问题,这只是 The server encountered an internal error that prevented it from fulfilling this request 问题的一种情况,具体错误如下图所示:
全栈程序员站长
2022/07/31
5.7K0
The server encountered an internal error that prevented it from fulfilling this request的一种解决办法[通俗易懂]
SpringBoot系列之自定义枚举类的数据校验注解
SpringBoot系列之自定义枚举类的数据校验注解 业务场景:数据校验,需要对枚举类型的数据传参,进行数据校验,不能随便传参。拓展,支持多个参数的枚举数据校验
SmileNicky
2021/12/17
3.3K1
SpringBoot系列之自定义枚举类的数据校验注解
java之Springmvc请求参数校验@Validated
SpringMVC支持的数据校验是JSR303的标准,通过在bean的属性上打上@NotNull、@Max等进行验证。JSR303提供有很多annotation接口,而SpringMVC对于这些验证是使用hibernate的实现,所以我们需要添加hibernate的一个validator包:
IT工作者
2022/05/17
1.6K0
Java Bean Validation的使用
因为在Spring Boot中默认已经包含了Hibernate Validator,所以不需要再引入额外的Jar包
十毛
2019/05/14
8810
bug问题总结
在@GetMapping 后加入produces = MediaType.APPLICATION_JSON_UTF8_VALUE 即可
shaoshaossm
2022/12/26
5960
bug问题总结
springboot源码解析之自定义参数解析
/savePerson?name=李四&age=18&pet.petName=黑皇&pet.petAge=3
九转成圣
2024/04/10
1430
springboot源码解析之自定义参数解析
前端报错400
Resolved [org.springframework.web.method.annotation.MethodArgumentTypeMismatchException: Failed to convert value of type ‘java.lang.String’ to required type ‘java.util.Date’; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [java.util.Date] for value ”; nested exception is java.lang.IllegalArgumentException]
全栈程序员站长
2022/06/30
1.1K0
@Validated注解和@Valid注解区别
在之前的Spring Boot 版本中,hibernate-validator是作为默认引入的web开发的集成package,但是在我最新使用的Spring Boot 2.3.0.RELEASE已经不是默认引入的了,所以需要通过上面的maven坐标单独引入。
大忽悠爱学习
2021/12/07
1.3K0
@Validated注解和@Valid注解区别
DataBinder MethodArgumentTypeMismatchException 前后端参数转化异常
当后端接受参数为int类型,但是前端却误传了一个"" 空的字符串,那么就会报这个DataBinder过程失败。
MickyInvQ
2022/11/06
5880
一文教你实现 SpringBoot 中的自定义 Validator 和错误信息国际化配置
本文通过示例说明,在 Springboot 中如何自定义 Validator,以及如何实现国际化的错误信息返回。注意,本文代码千万别直接照抄,有可能会出大事情的。先留个悬念,读者朋友们能从中看出有什么问题吗?
程序猿石头
2020/07/14
4.4K0
一文教你实现 SpringBoot 中的自定义 Validator 和错误信息国际化配置
如何优雅的写 Controller 层代码?
本篇主要要介绍的就是 controller 层的处理,一个完整的后端请求由 4 部分组成:
终码一生
2022/09/08
9260
如何优雅的写 Controller 层代码?
Java Integer源码解读
1、引言 public class IntegerDemo { public static void main(String[] args){ Integer i=10;
程裕强
2018/01/02
8950
Java Integer源码解读
The request sent by the client was syntactically incorrect ()"解决办法
使用Spring MVC3框架时,可能会遇到这个问题,请求后台没有任何响应,页面显示
traffic
2020/04/09
2.3K0
推荐阅读
相关推荐
补习系列-springboot 参数校验详解
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
本文部分代码块支持一键运行,欢迎体验
本文部分代码块支持一键运行,欢迎体验