Playframework 播放框架返回错误:找不到适合ok的方法(ArrayList<;String[]>;)]

Playframework 播放框架返回错误:找不到适合ok的方法(ArrayList<;String[]>;)],playframework,Playframework,我希望play framework将arraylist发送到我的android应用程序。所以我可以在android应用程序上查看列表。 但play框架无法返回ArrayList) 我怎样才能解决这个问题? 多谢各位 public static Result get_LatestList() throws ClassNotFoundException, SQLException { String latestList = ""; ArrayList<Strin

我希望play framework将arraylist发送到我的android应用程序。所以我可以在android应用程序上查看列表。 但play框架无法返回ArrayList) 我怎样才能解决这个问题? 多谢各位

public static Result get_LatestList() throws ClassNotFoundException,
        SQLException {
    String latestList = "";
    ArrayList<String[]> etList = new ArrayList<String[]>(); 

    MultipartFormData body = request().body().asMultipartFormData();
    String pageNumber = body.asFormUrlEncoded().get("pageNumber")[0];
    Connection conn = null;
    Statement stmt = null;
    ResultSet rs = null;

    Class.forName("com.mysql.jdbc.Driver");
    conn = DriverManager.getConnection("jdbc:mysql://localhost/iea_db",
            "rt", "yt");
    stmt = conn.createStatement();
    rs = stmt.executeQuery("select * from List_Table;");
    while (rs.next()) {
        String[] oneSet = new String[4];

        oneSet[0] = rs.getString("userName");
        oneSet[1] = rs.getString("idName");
        oneSet[2] = rs.getString("comment");
        oneSet[3] = rs.getString("rank");
        etList.add(oneSet);
    }

    conn.close();                   
    return ok(etList);
}
public static Result get_LatestList()抛出ClassNotFoundException,
SQLException{
字符串latestList=“”;
ArrayList etList=新建ArrayList();
MultipartFormData body=request().body().asMultipartFormData();
字符串pageNumber=body.asFormUrlEncoded().get(“pageNumber”)[0];
连接conn=null;
语句stmt=null;
结果集rs=null;
Class.forName(“com.mysql.jdbc.Driver”);
conn=DriverManager.getConnection(“jdbc:mysql://localhost/iea_db",
“rt”、“yt”);
stmt=conn.createStatement();
rs=stmt.executeQuery(“从列表中选择*);
while(rs.next()){
字符串[]oneSet=新字符串[4];
oneSet[0]=rs.getString(“用户名”);
oneSet[1]=rs.getString(“idName”);
oneSet[2]=rs.getString(“注释”);
oneSet[3]=rs.getString(“秩”);
etList.add(oneSet);
}
康涅狄格州关闭();
返回ok(etList);
}

我找到了一个解决方案:使用Json 在play framework中,执行以下操作:

    ObjectNode result = Json.newObject();

    result.put("draw", Integer.valueOf(params.get("draw")[0]));
    result.put("recordsTotal", iTotalRecords);
    result.put("recordsFilter", iTotalDisplayRecords);

    return ok(result);
  @Override
    protected JSONObject doInBackground(String... _uri) {
        HttpClient httpClient = new DefaultHttpClient();
        HttpGet httpGet = new HttpGet(_uri[0]);
        try {
            HttpResponse httpResponse = httpClient.execute(httpGet);
            if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
                httpResponse.getEntity().writeTo(outputStream);
                outputStream.close();
                return new JSONObject(outputStream.toString());
            } else {
                httpResponse.getEntity().getContent().close();
                throw new IOException();
            }
        } catch (IOException e) {
            e.printStackTrace();
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return null;
    }
在android中,执行以下操作:

    ObjectNode result = Json.newObject();

    result.put("draw", Integer.valueOf(params.get("draw")[0]));
    result.put("recordsTotal", iTotalRecords);
    result.put("recordsFilter", iTotalDisplayRecords);

    return ok(result);
  @Override
    protected JSONObject doInBackground(String... _uri) {
        HttpClient httpClient = new DefaultHttpClient();
        HttpGet httpGet = new HttpGet(_uri[0]);
        try {
            HttpResponse httpResponse = httpClient.execute(httpGet);
            if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
                httpResponse.getEntity().writeTo(outputStream);
                outputStream.close();
                return new JSONObject(outputStream.toString());
            } else {
                httpResponse.getEntity().getContent().close();
                throw new IOException();
            }
        } catch (IOException e) {
            e.printStackTrace();
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return null;
    }

我找到了一个解决方案:使用Json 在play framework中,执行以下操作:

    ObjectNode result = Json.newObject();

    result.put("draw", Integer.valueOf(params.get("draw")[0]));
    result.put("recordsTotal", iTotalRecords);
    result.put("recordsFilter", iTotalDisplayRecords);

    return ok(result);
  @Override
    protected JSONObject doInBackground(String... _uri) {
        HttpClient httpClient = new DefaultHttpClient();
        HttpGet httpGet = new HttpGet(_uri[0]);
        try {
            HttpResponse httpResponse = httpClient.execute(httpGet);
            if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
                httpResponse.getEntity().writeTo(outputStream);
                outputStream.close();
                return new JSONObject(outputStream.toString());
            } else {
                httpResponse.getEntity().getContent().close();
                throw new IOException();
            }
        } catch (IOException e) {
            e.printStackTrace();
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return null;
    }
在android中,执行以下操作:

    ObjectNode result = Json.newObject();

    result.put("draw", Integer.valueOf(params.get("draw")[0]));
    result.put("recordsTotal", iTotalRecords);
    result.put("recordsFilter", iTotalDisplayRecords);

    return ok(result);
  @Override
    protected JSONObject doInBackground(String... _uri) {
        HttpClient httpClient = new DefaultHttpClient();
        HttpGet httpGet = new HttpGet(_uri[0]);
        try {
            HttpResponse httpResponse = httpClient.execute(httpGet);
            if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
                httpResponse.getEntity().writeTo(outputStream);
                outputStream.close();
                return new JSONObject(outputStream.toString());
            } else {
                httpResponse.getEntity().getContent().close();
                throw new IOException();
            }
        } catch (IOException e) {
            e.printStackTrace();
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return null;
    }

只是一个建议,但可能删除不相关的标签,只保留与您当前使用的版本(以及您可以证明这一点适用的版本)?抱歉,我将编辑它只是一个建议,但可能删除不相关的标签,只保留与您当前使用的版本(以及您可以证明这一点适用的版本)的标签对不起,我会编辑它