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