有没有办法在@controller级别添加根元素,而不是在应用程序级别。我需要采用以下格式的回复
{"BaseResponse":{"HeaderResponse":{"prop1":"test","prop2":"1"},"DetailResponse":[{"recordDesc":"record1","recordId":1},{"recordDesc":"record1","recordId":1}]}}
但我没有得到" BaseResponse"在根
{"HeaderResponse":{"prop1":"test","prop2":"1"},"DetailResponse":[{"recordDesc":"record1","recordId":1},{"recordDesc":"record1","recordId":1}]}
我不想在应用程序级别配置WRAP_ROOT_VALUE,如下所示。
public class SpringMVCJacksonObjectMapper extends ObjectMapper
{
public SpringMVCJacksonObjectMapper()
{
super();
this.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
this.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
}
}