/** * Send POST request */ public static String post(String url, Map<String, String> queryParas, String data, Map<String, String> headers) { HttpURLConnection conn = null; try { // conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded"); conn = getHttpConnection(buildUrlWithQueryString(url, queryParas), POST, headers); conn.connect(); if (data != null) { OutputStream out = conn.getOutputStream(); out.write(data.getBytes(CHARSET)); // ??? out.flush(); out.close(); } return readResponseString(conn); } catch (Exception e) { throw new RuntimeException(e); } finally { if (conn != null) { conn.disconnect(); } } }
一直不明白这个工具类中的String data参数代表什么?
比如说,现在想用这个HttpKit工具类模仿一个普通的jquery ajax post请求,
这个data参数应该如何设置比较好?当然,基本功比较菜,Http工具类里面的细节一直没有理解。
项目:JFinal
nameA=1&nameB=2&nameC=3