我很新玩,开始使用Play 2.0。
尝试在视图中使用jqgrid但无法显示数据,下面是代码:
控制器:
public static Result userLogs(String criteria) throws JSONException {
JSONObject responcedata = new JSONObject();
JSONArray logData = UserLogs.getUserlogs();
responcedata.put("page", 1);
responcedata.put("records", 10);
responcedata.put("rows", logData);
response().setContentType("application/json");
return ok(userlogs.render(responcedata));
}
模特课:
public static JSONArray getUserlogs(){
String query = "select date from user where user_id=1 and resp=1";
List<SqlRow> userLogs = Ebean.createSqlQuery(query).findList();
JSONArray cellarray = new JSONArray();
int tableSize = userLogs.size();
int i = 0;
while (i < tableSize) {
JSONObject cellObj = new JSONObject();
JSONArray cell = new JSONArray();
cell.put(i + 1);
cell.put(userLogs.get(i).getTimestamp("date"));
try {
cellObj.put("cell", cell);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
cellarray.put(cellObj);
i++;
}
return cellarray;
}
观点:
的jQuery( “#格”)。的jqGrid({
url:"@Application.userLogs(),
datatype : 'json',
colNames:['S.No','date'],
colModel:[
{name:'sno',index:'sno', width:50, sorttype:"int"},
{name:'date',index:'date', width:150, sorttype:"date"}
],
jsonReader : {
root: "rows",
page: "page",
total: "total",
records: "records",
cell: "cell",
loadOnce: "true",
id: "id",
userdata: "userdata"
},
width: 900,
height: 220,
rowNum:10, rowList:[10,20,30],
pager: '#pager',
sortname: 'id',
viewrecords: true,
gridview: true,
sortorder: "desc",
loadonce:true,
ignoreCase:true,
multiselect: true,
});
});
以下是异常::
play.api.Application $$ anon $ 1:执行异常[[RuntimeException:java.lang.StackOverflowError]] at play.api.Application $ class.handleError(Application.scala:289)〜[play_2.10.jar:2.1.1] at play.api.DefaultApplication.handleError(Application.scala:383)[play_2.10.jar:2.1.1] at play.core.server.netty.PlayDefaultUpstreamHandler $$ anon $ 2 $$ anonfun $ handle $ 1.apply(PlayDefaultUpstreamHandler.scala:144)[play_2.10.jar:2.1.1] at play.core.server.netty.PlayDefaultUpstreamHandler $$ anon $ 2 $$ anonfun $ handle $ 1.apply(PlayDefaultUpstreamHandler.scala:140)[play_2.10.jar:2.1.1] at play.api.libs.concurrent.PlayPromise $$ anonfun $ extend1 $ 1.apply(Promise.scala:113)[play_2.10.jar:2.1.1] at play.api.libs.concurrent.PlayPromise $$ anonfun $ extend1 $ 1.apply(Promise.scala:113)[play_2.10.jar:2.1.1] java.lang.RuntimeException:java.lang.StackOverflowError at play.libs.F $ Promise $ 6.apply(F.java:401)〜[play_2.10.jar:2.1.1] 在scala.concurrent.Future $$ anonfun $ map $ 1.liftedTree2 $ 1(Future.scala:253)〜[scala-library.jar:na] 在scala.concurrent.Future $$ anonfun $ map $ 1.apply(Future.scala:249)〜[scala-library.jar:na] 在scala.concurrent.Future $$ anonfun $ map $ 1.apply(Future.scala:249)〜[scala-library.jar:na] 在scala.concurrent.impl.CallbackRunnable.run(Promise.scala:29)〜[scala-library.jar:na] at akka.dispatch.BatchingExecutor $ Batch $$ anonfun $ run $ 1.liftedTree1 $ 1(BatchingExecutor.scala:67)〜[akka-actor_2.10.jar:na] java.lang.StackOverflowError:null 在com.mysql.jdbc.Util.handleNewInstance(Util.java:431)〜[mysql-connector-java-5.1.18.jar:na] 在com.mysql.jdbc.PreparedStatement.getInstance(PreparedStatement.java:872)〜[mysql-connector-java-5.1.18.jar:na] 在com.mysql.jdbc.ConnectionImpl.clientPrepareStatement(ConnectionImpl.java:1490)〜[mysql-connector-java-5.1.18.jar:na] 在com.mysql.jdbc.ConnectionImpl.prepareStatement(ConnectionImpl.java:4253)〜[mysql-connector-java-5.1.18.jar:na] 在com.mysql.jdbc.ConnectionImpl.prepareStatement(ConnectionImpl.java:4152)〜[mysql-connector-java-5.1.18.jar:na] 在com.jolbox.bonecp.ConnectionHandle.prepareStatement(ConnectionHandle.java:820)〜[bonecp.jar:0.7.1.RELEASE]
请告诉我如何处理这种情况并使用jqgrid在视图中显示列表。 实现这一目标的任何其他方法也有帮助。
感谢.. !!!