当控制器方法返回@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
发布评论