我试图让 Spring 3.2 MVC 返回没有默认标签的 JSON 响应。
例如,
@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}
谢谢。