【发布时间】:2017-04-07 09:08:56
【问题描述】:
我正在使用简单的@RestController 开发一个 Spring Boot 应用程序。
这是困扰我的代码 sn-p。
else if (validators.isCommentValid(submission) == false)
throw new WebApplicationException("comment field is empty", 400);
//throw new BadRequestException("Comment field cannot be empty");
//throw new HTTPException(400);
背后的思想:当comment field为空时,返回400状态(Bad Request)。
我尝试了多个 JEE(基于 avax.ws.rs)异常,它们在中继消息等方面工作正常,但邮递员返回的状态始终为 500。
不知道我错过了什么,有什么想法吗?
【问题讨论】:
标签: java spring exception-handling jax-rs