We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSONObject result = new JSONObject(); result.put("ok", false); if (id == null || id.trim().isEmpty()) { result.put("msg", "invalid parameter"); } else { Connection conn = null; PreparedStatement pstmt = null; ResultSet rs = null; try { conn = getConnection(); pstmt = conn.prepareStatement("select order_no, order_amt from orders"); rs = pstmt.executeQuery(); JSONArray array = new JSONArray(); while (rs.next()) { JSONObject o = new JSONObject(); String orderNo = nvl(rs.getString("order_no")); String orderAmt = nvl(rs.getString("order_amt")); o.put("orderNo", orderNo); o.put("orderAmt", orderAmt); array.add(o); } result.put("ok", true); result.put("data", array); } catch (Exception e) { e.printStackTrace(); result.put("msg", "Error get order:" + e.getMessage()); } finally { cleanup(conn, pstmt, rs); } } renderJson(response, result);
renderJson()
protected void renderJson(HttpServletResponse response, JSONObject json) { String content = json.toJSONString(); response.addHeader("Content-Type", "application/json"); response.addHeader("Access-Control-Allow-Origin", "*"); response.getWriter().print(content); }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
object to string
renderJson()
The text was updated successfully, but these errors were encountered: