我有一个包含多行条目的数据表,并希望将其设置为服务器端。问题是我无法得到sEcho
对我request()
来说总是如此null
的东西。我的代码如下:
$.fn.loadTable = function (url,options) {
// check if the options exists or not, defaults to false
var activity = ((typeof options === "undefined") || (typeof options.activity === "undefined")) ? false : options.activity;
var document = ((typeof options === "undefined") || (typeof options.document === "undefined")) ? false : options.document;
var idable = ((typeof options === "undefined") || (typeof options.idable === "undefined")) ? false : options.idable;
var element = this;
var table = element.find("table").dataTable({
"bProcessing": true,
"bServerSide": true,
"bPaginate": false,
"bLengthChange": false,
"bFilter": true,
"bSort": true,
"bInfo": false,
"bAutoWidth": false,
"oLanguage": {
"sZeroRecords": "No data available"
}
});
$.ajax({
'url':url,
dataType:"json",
type:'GET',
success: function(data) {
$.each(data,function(index,item) {....
我的控制器看起来像这样:
public static Result getActivitiesByParticipant() throws UnsupportedEncodingException {
List<Container> activities = CMISConnection.listActivitiesByParticipant(session("user"));
// TODO: change to server side
// manipulate jsonresult
ObjectNode result = Json.newObject();
Map<String, String[]> params = request().queryString();
result.put("sEcho", Integer.valueOf(params.get("sEcho")[0]));
result.put("iTotalRecords", activities.size());
result.put("iTotalDisplayRecords", activities.size());
ArrayNode an = result.putArray("aaData");
for(Container c : activities) {
ObjectNode row = Json.newObject();
row.put("0", c.getName());
row.put("1", c.getCreator());
row.put("2", dateFormat.format(c.getCreationDate()));
row.put("3", c.getOptischerBetreff());
an.add(row);
}
return ok(result);
}
params
null
对我来说总是如此。我配置了路线
GET /activity/participant controllers.Content.getActivitiesByParticipant()