【发布时间】:2015-08-09 08:29:30
【问题描述】:
我正在研究从服务器端填充数据的数据,我面临的问题是它总是给出一个显示的警报框
DataTables 警告:表 id=firmtable - 请求的未知参数 '1' 表示第 0 行。有关此错误的更多信息,请参阅 http://datatables.net/tn/4我无法追踪这个问题可能在哪里 是
我的 json
{
"sEcho":"3",
"iTotalRecords":10,
"iTotalDisplayRecords":10,
"aaData":
"[
{\"LogId\":\"108\",
\"tableName \":\"game\",
\"columnName\":\"Status\",
\"oldValue\":\"0\",
\"newValue\":\"1\",
\"changeTypeText\":\"Update \",
\"changedByName\":\"abc\"}
]"
}
这就是我在服务器端的工作方式
Iterator<LogInfo> i = logList.iterator();
int row = 0;
JsonObject returnObj = new JsonObject();
JsonArray dataArray = new JsonArray();
while (i.hasNext()) {
LogInfo logInfo = (LogInfo) i.next();
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("logId", logInfo.getLogId());
jsonObject.addProperty("tableName", logInfo.getTableName());
jsonObject.addProperty("columnName", logInfo.getColumnName());
jsonObject.addProperty("oldValue", logInfo.getOldValue());
jsonObject.addProperty("newValue", logInfo.getNewValue());
jsonObject.addProperty("changeTypeText", logInfo.getChangeTypeText());
jsonObject.addProperty("changedByName", logInfo.getChangedByName());
row++;
dataArray.add(jsonObject.getAsJsonObject());
}
returnObj.addProperty("sEcho", "3");
returnObj.addProperty("iTotalRecords", row);
returnObj.addProperty("iTotalDisplayRecords", row);
returnObj.addProperty("aaData", dataArray.toString());
PrintWriter out = response.getWriter();
Gson gson = null;
GsonBuilder builder = new GsonBuilder();
builder.setDateFormat(JarolConstants.AJAX_DATE_FORMAT);
gson = builder.create();
String resultStr = gson.toJson(returnObj);
out.print(resultStr);
out.close();
客户端发生了什么,mytable 没有被填充 html代码
脚本
$(document).ready(function() {
$('#firmtable').dataTable({
"bProcessing" : true,
bServerSide : true,
sAjaxSource : "./log!list.action",
sServerMethod : "POST"
});
}); </script>
<table id="firmtable">
<thead>
<tr class="detail">
<th><s:property value="getText('auditLog.jsp.transactionId')" /></th>
<th><s:property value="getText('auditLog.jsp.tableName')" /></th>
<th><s:property value="getText('auditLog.jsp.columnName')" /></th>
<th><s:property value="getText('auditLog.jsp.oldValue')" /></th>
<th><s:property value="getText('auditLog.jsp.newValue')" /></th>
<th><s:property value="getText('auditLog.jsp.changeTypeId')" /></th>
<th><s:property value="getText('auditLog.jsp.changeBy')" /></th>
<th><s:property value="getText('auditLog.jsp.changeOn')" /></th>
<th class="edit"><s:property value="getText('global.action')" /></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
编辑 我也尝试将 sEcho 值设置为
returnObj.addProperty("sEcho", Integer.parseInt(request.getParameter("sEcho")));
但没有结果,我遇到了同样的问题
我得到的结果是表格第一列填充了这样的 aaData 内容
[ { 大号 ○ G 一世 d 1 0 8 即第一列中的单个字母
【问题讨论】:
标签: java jquery datatable server-side