【发布时间】:2017-05-02 16:38:06
【问题描述】:
我有以下方法:
@ExceptionHandler(InvalidPriceUpdateException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public String handleInvalidPriceUpdateException(InvalidPriceUpdateException e) throws JsonProcessingException {
return objectMapper.writeValueAsString(new HttpErrorDTO(e.getMessage()));
}
我看到(在调试中)它调用但在浏览器中我看到 500 错误(而不是 HttpStatus.BAD_REQUEST)。并且http响应的内容包含异常信息(而不是HttpErrorDTO结构)。
我的代码有什么问题?
【问题讨论】:
标签: java spring spring-mvc exception-handling exceptionhandler