1
我試圖讓Spring 3.2 MVC返回一個沒有默認標籤的JSON響應。Spring 3.2 Web MVC @ModelAttribute without label
例如,
@Controller
@RequestMapping("/dt")
public class DTAgentsController {
@ModelAttribute
@RequestMapping(method = RequestMethod.GET, produces = "application/json;UTF-8")
public DTResponse agents() {
DTResponse resp = new DTResponse();
resp.setsEcho(1);
resp.setiTotalDisplayRecords(10);
resp.setiTotalRecords(50);
return resp;
}
}
回報
{"DTResponse":{"sEcho":1,"iTotalRecords":50,"iTotalDisplayRecords":10}}
我只想JSON輸出爲
{"sEcho":1,"iTotalRecords":50,"iTotalDisplayRecords":10}
感謝。
謝謝:)。奇蹟般有效。 – user2176499 2013-03-16 12:32:04