spring responsejson with responsebody

编程入门 行业动态 更新时间:2024-10-22 20:22:46
本文介绍了spring responsejson with responsebody的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当控制器方法返回@responsebody时,即使我把

when controller method return is @responsebody , even if i put

<bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView"> <property name="prefixJson" value="true" /> </bean>

没有&& {}插入json数据的前面。有谁知道是什么原因?

there will no && {} insert at the front of json data. anyone knows what is reason?

推荐答案

中的JSON> @RequestBody / @ResponseBody 由 MappingJacksonHttpMessageConverter 处理,该配置在 AnnotationMethodHandlerAdapter.messageConverters 。

JSON in @RequestBody/@ResponseBody is handled by MappingJacksonHttpMessageConverter which is configured in AnnotationMethodHandlerAdapter.messageConverters.

在不干扰其他功能的情况下配置它的简单方法是创建一个 BeanPostProcessor 来拦截创建 AnnotationMethodHandlerAdapter ,例如,参见这里。

The easy way to configure it without interference with other features is to create a BeanPostProcessor to intercept creation of AnnotationMethodHandlerAdapter, see, for example, here.

更多推荐

spring responsejson with responsebody

本文发布于:2023-11-26 21:00:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1635178.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:spring   responsejson   responsebody

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!