課程
/后端開發(fā)
/Java
/Java微信公眾號(hào)開發(fā)進(jìn)階
Exception in thread "main" java.lang.NullPointerException
2017-09-05
源自:Java微信公眾號(hào)開發(fā)進(jìn)階 3-2
正在回答
public?static?JSONObject?doPost(String?url,String?outUrl){ JSONObject?jsonObject=null; CloseableHttpClient?httpClient?=?HttpClients.createDefault(); HttpPost?httpPost?=?new?HttpPost(); httpPost.setEntity(new?StringEntity(outUrl,"UTF-8")); URI?uri?=?null; try?{ uri?=?new?URI(url);//視頻中忘了加url,所以輸出httpPost,會(huì)顯示POST?null?HTTP/1.1 }? catch?(URISyntaxException?e1)?{ e1.printStackTrace(); } httpPost.setURI(uri); System.out.println(httpPost);//POST?null?HTTP/1.1 try?{ HttpResponse?reponse?=?httpClient.execute(httpPost); System.out.println("d"); String?result?=?EntityUtils.toString(reponse.getEntity(),"UTF-8"); System.out.println(result); jsonObject=JSONObject.fromObject(result); System.out.println(jsonObject); }? catch?(ClientProtocolException?e)?{ e.printStackTrace(); }? catch?(IOException?e)?{ e.printStackTrace(); } return?jsonObject; }
舉報(bào)
Java微信公眾號(hào)開發(fā)的進(jìn)階課程,在入門的基礎(chǔ)上更加深入
1 回答為什么提示創(chuàng)建菜單成功還報(bào)空指針異常
3 回答為什么好多老師拋出異常的地方我都不需要呢?
4 回答運(yùn)行結(jié)果是空指針
1 回答我已經(jīng)解決了獲取access_token空指針的問(wèn)題
1 回答dopost
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2017-09-06