| | |
| | | HttpURLConnection con = null; |
| | | URL u = null; |
| | | String wxMsgXml = null; |
| | | JSONObject obj = null; |
| | | try { |
| | | StringBuilder dataP = new StringBuilder(); |
| | | if (keyValues != null && !keyValues.isEmpty()) { |
| | |
| | | os.write(data.getBytes("utf-8")); |
| | | } |
| | | |
| | | if (con.getResponseCode() != 200) |
| | | if (con.getResponseCode() != 200){ |
| | | throw new RuntimeException("请求url失败"); |
| | | } |
| | | // 读取返回内容 |
| | | wxMsgXml = IOUtils.toString(con.getInputStream(), "utf-8"); |
| | | // //System.out.println("HttpURLUtil:"+wxMsgXml); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | obj = new JSONObject(); |
| | | try { |
| | | obj.put("status", 1); |
| | | obj.put("errMsg", e.getMessage()); |
| | | } catch (JSONException e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } finally { |
| | | if (con != null) { |
| | | con.disconnect(); |