我正在使用Jackson和ContentNegotiatingViewResolver
从Spring控制器返回JSON。
当我像这样在Spring中定义一个方法时
public ModelMap save(FileUploadBean uploadItem, ParameterBean params) throws JsonParseException, JsonMappingException, IOException
并返回一个ModelMap
ModelMap model = new ModelMap();
model.addAttribute("output","Save was ok");
return model;
Spring总是将uploadItem
和params
附加到JSON响应中,尽管我已经从未将这两个添加到ModelMap中。
结果看起来像那样
{
"parameterBean": {
"values": {
"json": "{\"seizure\":{\"id\":1},\"classDocumentType\":{\"id\":1},\"seizureDocumentI18ns\":[{\"id\":\"\",\"comment\":\"123\",\"matLanguageCode\":\"\"}]}"
}
},
"output": ["Save was ok"],
"fileUploadBean": {
"file": {
"originalFilename": "Form.png",
"fileItem": {
"contentType": "image/png"
}
}
}
}
这是默认行为,是否描述了......
答案 0 :(得分:1)
面临类似的问题 -
查看以下链接。我发布了一项决议。
Spring JSON Jackson Marshaller adding additional parameter in my response object