Java 如何打印发送到Spring@RestController时出错的json?

Java 如何打印发送到Spring@RestController时出错的json?,java,json,spring,spring-mvc,tomcat,Java,Json,Spring,Spring Mvc,Tomcat,我的日志中出现以下错误: 2016-04-06 09:22:24,623 W DefaultHandlerExceptionResolver - Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: Could not read document: Can not deserialize instance of java.lang.String out of

我的日志中出现以下错误:

2016-04-06 09:22:24,623 W DefaultHandlerExceptionResolver - Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: Could not read document: Can not deserialize instance of java.lang.String out of START_OBJECT token
 at [Source: java.io.PushbackInputStream@540c46e3; line: 1, column: 1]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.lang.String out of START_OBJECT token
 at [Source: java.io.PushbackInputStream@540c46e3; line: 1, column: 1]
这很难调试,因为它没有告诉我发送给端点的是什么JSON。如何打印出它试图反序列化的json


我们使用tomcat作为web容器

Jackson使用其流式API解析JSON,它不会使用所有的API来打印JSON。添加一个转储HTTP请求的阀(取决于servlet容器),或者添加一个执行相同操作的
过滤器
/
拦截器
。您必须小心,允许两次使用
InputStream
。另一个选项是实现第二个处理程序,该处理程序接收@RequestBody并将其转储到日志中。查看其中一个答案建议您实现@ExceptionHandler来处理和转储HttpMessageEndableException。