我已经使用Jackson/JSON设置了春季REST,并且一切正常.
I have spring REST set up fine using Jackson/JSON and everything works.
但是我故意在消息的结构中引入了一个错误,该错误导致了400-错误的请求.但是服务器上没有日志输出.我所期望的错误将是杰克逊未知属性异常"之类的东西,但它被捕获,并且向客户端发送了400错误,但服务器上没有该异常的日志.
But I knowingly introduced an error in the structure of the message which resulted in a 400 - Bad Request. But there was no log output on the server. The error I would be expecting would be something like "Jackson unknown property exception" or whatever but it was caught and a 400 error was sent to the client, but no log of the exception on the server.
我不想明确调试服务器上的所有内容,但我希望像这样的Spring网络级异常明确标记为错误.
I don't want to debug everything on the server clearly, but I want Spring network level exceptions like this clearly labelled as error.
打开此功能的正确方法是什么?
What is the correct way to switch this on?
谢谢!
推荐答案@ExceptionHandler @ResponseStatus(HttpStatus.BAD_REQUEST) public void handle(HttpMessageNotReadableException e) { logger.warn("Returning HTTP 400 Bad Request", e); }
更多推荐
使用Jackson的Spring REST
发布评论