0
有没有办法在@controller级别而不是在应用程序级别添加根元素。我需要响应以下格式Spring在控制器级别添加Json根名称
{"BaseResponse":{"HeaderResponse":{"prop1":"test","prop2":"1"},"DetailResponse":[{"recordDesc":"record1","recordId":1},{"recordDesc":"record1","recordId":1}]}}
但我不从根本
{"HeaderResponse":{"prop1":"test","prop2":"1"},"DetailResponse":[{"recordDesc":"record1","recordId":1},{"recordDesc":"record1","recordId":1}]}
我不希望在应用程序级别,如下配置WRAP_ROOT_VALUE得到“BaseResponse”。
public class SpringMVCJacksonObjectMapper extends ObjectMapper
{
public SpringMVCJacksonObjectMapper()
{
super();
this.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
this.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
}
}