資源簡介
用java編寫了http Post的請求代碼,通過發送請求的 URL,獲取遠程資源的響應結果,入參為json字符串。使用到httpPost,CloseableHttpClient
代碼片段和文件信息
package?com.edu.service.impl;
import?org.apache.http.HttpEntity;
import?org.apache.http.client.methods.CloseableHttpResponse;
import?org.apache.http.client.methods.HttpPost;
import?org.apache.http.entity.StringEntity;
import?org.apache.http.impl.client.CloseableHttpClient;
import?org.apache.http.impl.client.HttpClients;
import?org.apache.http.util.EntityUtils;?
public?class?SSLClient?{
public?static?void?main(String[]?args)?{
try?{
sendHttpPost();
}?catch?(Exception?e)?{
}
}
??
??
??public?static?String?sendHttpPost()?throws?Exception?{
??String?aa?=?“{\“auditname\“:?\“10\“\“operationtime\“:?1526352766312\“createtime\“:?1526352766312\“operationuser\“:?\“10\“\“user\“:?\“10\“\“terminalip\“:?\“10\“\“level\“:?1
評論
共有 條評論