[英]spring custom json message converter for controller
I would like to configure Custom JSON message converter which extending MappingJacksonHttpMessageConverter
to work in Specific Controller. 我想配置自定义JSON消息转换器,该转换器将MappingJacksonHttpMessageConverter
扩展为在特定控制器中工作。 I have tried using AnnotationMethodHandlerAdapter
but that would add it to every end point /
controller. 我尝试使用AnnotationMethodHandlerAdapter
但是会将其添加到每个端点/
控制器。
Also FYI there are other custom message converters which are configured as AnnotationMethodHandlerAdapter
. 仅供参考,还有其他自定义消息转换器,它们配置为AnnotationMethodHandlerAdapter
。
Depends on your use-case. 取决于您的用例。
As Sotirios wrote in his comment, the easiest way is if you marshall and unmarshall your requests manually. 正如Sotirios在他的评论中所写,最简单的方法是手动编组和取消编组请求。
ObjectMapper
配置ObjectMapper
You can configure ObjectMapper
to use different settings based on the class of the object it is (un)marshalling. 您可以将ObjectMapper
配置为根据要(取消)编组的对象的类使用不同的设置。
You can implement your own HandlerMethodReturnValueHandler
and / or HandlerMethodArgumentResolver
. 您可以实现自己的HandlerMethodReturnValueHandler
和/或HandlerMethodArgumentResolver
。 These have access to handler method annotations. 它们可以访问处理程序方法注释。 You can implement your own annotation and pretty much implement any custom conversion behavior. 您可以实现自己的注释,几乎可以实现任何自定义转换行为。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.