我很新玩,开始使用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]在play.api.libs的play.api.libs.concurrent.PlayPromise $$ anonfun $ extend1 $ 1.apply(Promise.scala:113)[play_2.10.jar:2.1.1] .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] at scala.concurrent.Future $$ anonfun $ map $ 1.liftedTree2 $ 1(Future.scala:253)〜[scala-library.jar :na] a t scala.concurrent.Future $$ anonfun $ map $ 1.apply(Future.scala:249)〜[scala-library.jar:na] at scala.concurrent.Future $$ anonfun $ map $ 1.apply(Future.scala: 249)〜[scala-library.jar:na] at 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 at com.mysql.jdbc.Util.handleNewInstance(Util.java:431)〜 [mysql-connector-java-5.1.18.jar:na] at com.mysql.jdbc.PreparedStatement.getInstance(PreparedStatement.java:872)〜[mysql-connector-java-5.1.18.jar:na] at com .mysql.jdbc.ConnectionImpl.clientPrepareStatement(ConnectionImpl.java:1490)〜[mysql-connector-java-5.1.18.jar:na] at com.mysql.jdbc.ConnectionImpl.prepareStatement(ConnectionImpl.java:4253)~ [ mysql-connector-java-5.1.18.jar:na] at com.mysql.jdbc.ConnectionImpl.prepareStatement(ConnectionImpl.java:4152)〜[mysql-connector-java-5.1.18.jar:na] at com . jolbox.bonecp .ConnectionHandle.prepareStatement(ConnectionHandle.java:820)~ [bonecp.jar:0.7.1.RELEASE]

让我知道如何处理这种情况,并使用jqgrid在视图中显示列表 . 任何替代方法来实现这一点也有帮助 .

谢谢..!!!