Better exception message for missing @RequestBody method parameter
https://jira.spring.io/browse/SPR-12888
Description
When I use @RequestBody on one of my controllers for a required parameter, I need some useful way of saying which parameter was missing if it's not there. The exception message I see currently looks like this:
Required request body content is missing: org.springframework.web.method.HandlerMethod$HandlerMethodParameter@a8b8886e |
at org.springframework.test.util.MatcherAssertionErrors.assertThat(MatcherAssertionErrors.java:80) |
at org.springframework.test.util.JsonPathExpectationsHelper.assertValue(JsonPathExpectationsHelper.java:92) |
at org.springframework.test.web.servlet.result.JsonPathResultMatchers$1.match(JsonPathResultMatchers.java:56) |
at org.springframework.test.web.servlet.MockMvc$1.andExpect(MockMvc.java:152) |
... |
It would be nice if when that exception could have a reference to the parameter name that was missing, or if the message itself included it instead of the MethodParameter#toString(). I'll eventually want to internationalize the message I produce, so the parameter name is preferable.
Activity
- All
- Comments
- Work Log
- History
- Activity
- Transitions
The HttpMessageNotReadableException can be raised from many places where a method parameter does not apply so adding a new field to the exception isn't ideal. I considered sub-classing the exception but what I've done instead is to print the full method signature to improve the error message. Also we now support injecting the selected HandlerMethod into an @ExceptionHandler method so you can obtain the full information on the @RequestMapping method we were trying to call.
Resolving for now but feel free to comment further.
Better exception message for missing @RequestBody method parameter的更多相关文章
- CAS (10) —— JBoss EAP 6.4下部署CAS时出现错误exception.message=Error decoding flow execution的解决办法
CAS (10) -- JBoss EAP 6.4下部署CAS时出现错误exception.message=Error decoding flow execution的解决办法 jboss版本: jb ...
- Use Exception.ToString() instead of Exception.Message.
Exception.Message contains only the message (doh) associated with the exception. Example: Object ref ...
- java.lang.Exception: No tests found matching Method tes(com.bw.test.Testrefiect) from org.junit.vintage.engine.descriptor.RunnerRequest@3bfdc050 at org.junit.internal.requests.FilterRequest.getRunner
junit 方法 没有加上注解 @Test java.lang.Exception: No tests found matching Method tes(com.bw.test.Testre ...
- jenkins编辑报错Exception when publishing, exception message的解决办法
jenkins编辑报错Exception when publishing, exception message的解决办法 查看目标主机的磁盘空间是否占满,清理磁盘空间即可
- Exception message: /bin/bash: line 0: fg: no job control
这个错误是 我本地idea 远程调试hadoop集群出现的 Diagnostics: Exception from container-launch. Container id: container_ ...
- 记一次Jenkins 打包异常 ERROR: Exception when publishing, exception message [Failure]
今天早上打包一直都没有问题,突然有一次打包突然出现异常现象,如下: ERROR: Exception when publishing, exception message [Failure] Buil ...
- 错误:java.lang.Exception: No tests found matching Method testPrePage1(egou_manager_web.TestEBrand) from org.junit.internal.requests.ClassRequest@4f3cc73c
今天测试分页时出现以下错误: java.lang.Exception: No tests found matching Method testPrePage1(egou_manager_web.Tes ...
- How to receive JSON as an MVC 5 action method parameter
How to receive JSON as an MVC 5 action method parameter 解答1 Unfortunately, Dictionary has problems ...
- Yarn报错:Exception message: /bin/bash: line 0: fg: no job control
Exception message: /bin/bash: line 0: fg: no job control 这个错误是 本地idea跨平台远程调试hadoop集群出现的,在使用windows调用 ...
随机推荐
- 数据库事务的四个特性(ACID)、事务的隔离级别
事务是一个不可分割的最小逻辑工作单元. 事务具有四个特征:原子性( Atomicity ).一致性( Consistency ).隔离性( Isolation )和持久性( Durability ). ...
- Hidden Markov Models笔记
Andrew Ng CS229 讲义: https://pan.baidu.com/s/12zMYBY1NLzkluHNeMNO6MQ HMM模型常用于NLP.语音等领域. 马尔科夫模型(Markov ...
- jquery mobile - select and input - horizontal - in same line
控件组合的水平布局 select + input 在同一行 注意jquery mobile 的js 和css 的版本, 一些低版本 估计不支持 <!DOCTYPE html> <ht ...
- 转:自定义控件三部曲之动画篇——alpha、scale、translate、rotate、set的xml属性及用法
第一篇: 一.概述 Android的animation由四种类型组成:alpha.scale.translate.rotate,对应android官方文档地址:<Animation Resour ...
- OpenCV细化算法简单解析
细化算法它的原理也很简单: 我们对一副二值图像进行骨架提取,就是删除不需要的轮廓点,只保留其骨架点.假设一个像素点,我们定义该点为p1,则它的八邻域点p2->p9位置如下图所示,该算法考虑p1点 ...
- 【LDAP】Openldap导入数据
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://jerry12356.blog.51cto.com/4308715/1851186 ...
- linux命令strings
linux命令strings,其man信息如下:strings(1) GNU Development Tools ...
- Python常用模块二
一.time & datetime #_*_coding:utf-8_*_ import time # print(time.clock()) #返回处理器时间,3.3开始已废弃 , 改成了t ...
- jquery validation yyyy-MM-dd格式日期在ie中无法验证通过
自己开发的公众号,可以领取淘宝内部优惠券 问题 首先在ie6.7.8下面打开这个页面http://jqueryvalidation.org/date-method/,输入的日期格式为:yyyy-MM- ...
- Java入门之Tomcat运行
在上一篇<Java入门之Tomcat安装及环境变量配置>中提到,启动Tomcat要保持CMD下执行startup.bat的界面不关闭,才能访问Tomcat. 这是因为只有保持startup ...