Pergunta

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?

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top