【发布时间】:2016-11-03 18:03:17
【问题描述】:
我正在使用 SpringMVC,这是我的 POST 方法:
RequestMapping(value = "/test/handler",
method = RequestMethod.POST,
headers = {"Content-type=application/json"})
public String getOpen(@RequestBody String json, HttpServletRequest request) throws InterruptedException {
String result= json;
ObjectMapper mapper = new ObjectMapper();
DataJsonMailJet jsonobj = null;
try {
// read from file, convert it to jsonobj class
jsonobj = mapper.readValue(json, DataJsonMailJet.class);
// display to console
System.out.println(jsonobj);
} catch (JsonGenerationException e) {
e.printStackTrace();
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return (result);
}
问题是我的“json”对象甚至得到了这样的标题:
------------------------------2fe344dd21f3
Content-Disposition: form-data; name="0"
[{"event":"open","time":1467369924, .......}]
------------------------------2fe344dd21f3--
我试过去掉“标题”,但没有运气...... 有什么建议?谢谢
【问题讨论】:
标签: json spring-mvc post