3

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>  

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

cometta
  • 35,071
  • 77
  • 215
  • 324

1 Answers1

4

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

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.

Community
  • 1
  • 1
axtavt
  • 239,438
  • 41
  • 511
  • 482