Http协议使用封装jar包(commons-codec-1.3.jar、commons-httpclient-3.1.jar、commons-logging-1.1.jar)
简单使用方法:
public static void main(String[] args) {
// String str1 = "http://dev.d-smart.cn/Login";
// http协议路径
String str1 = "";
HttpClient httpClient = new HttpClient();
PostMethod method = new PostMethod(str1);
try {
// 需要添加的header数据
List headers = new ArrayList();
headers.add(new Header("", ""));
headers.add(new Header("", ""));
headers.add(new Header("", ""));
httpClient.getHostConfiguration().getParams().setParameter("http.default-headers", headers);
method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler());
// 需要添加的body数据
Part[] parts = {new StringPart("", "")};
method.setRequestEntity(new MultipartRequestEntity(parts, method.getParams()));
... ...
... ...
1