我以前在Spring @ResponseBody中发生过这种情况,这是因为没有随请求一起发送的accept标头。使用jQuery设置Accept标头可能很麻烦,但这对我有用
$.postJSON = function(url, data, callback) { return jQuery.ajax({ headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }, 'type': 'POST', 'url': url, 'data': JSON.stringify(data), 'dataType': 'json', 'success': callback });};@RequestBody使用Content-Type标头确定从客户端在请求中发送的数据的格式。@ResponseBody使用accept标头确定响应中将数据发送回客户端的格式。这就是为什么你需要两个标题。



