欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 汽车 > 新车 > HTTP Error 400 Bad request 问题分析解决

HTTP Error 400 Bad request 问题分析解决

2025/6/6 5:54:22 来源:https://blog.csdn.net/qq_35365160/article/details/148409068  浏览:    关键词:HTTP Error 400 Bad request 问题分析解决

在这里插入图片描述

文章目录

      • 1.问题描述:
      • 2.异常信息如下:
      • 3.分析异常信息:
      • 4.总结:


1.问题描述:

前端保存老是报错HTTP ERROR 400 Bad Request。经过异常分析得出是前端传参导致的后端框架的验证拦截,包的错误。

2.异常信息如下:


{"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"}

3.分析异常信息:

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
前端的参数应该是金额要么是空值,结果传输的时候传一个null,后台接收的时候是用bigDecimal 参数类型导致参数异常,报的400错误问题。

4.总结:

经过分析得出400错误code:数据框架的验证拦截前端传入的参数异常,参数类型异常,一般情况下出现400,都是前端传入的参数异常。

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词