【发布时间】:2015-10-28 11:25:22
【问题描述】:
我正在尝试为我的自定义异常提供动态消息,如下面的代码 sn-p 所示:
@ResponseStatus(value = HttpStatus.NOT_FOUND, reason = "Entity not found")
public class EntityNotFoundException extends RuntimeException {
public EntityNotFoundException(String msg) {
super(msg);
}
}
但是当我抛出它时总是如下所示:
throw new EntityNotFoundException("User entity not found");
在浏览器中,我收到消息“找不到实体”而不是“找不到用户实体”。
如何做到这一点?
【问题讨论】:
标签: spring spring-mvc