HttpClient总是报java.lang.NoClassDefFoundError:错误
具体代码如下:
public static boolean login()throws Exception{
HttpPost httpPost = new HttpPost(loginURL);
List<BasicNameValuePair> list = new ArrayList<>();
list.add(new BasicNameValuePair("username",""));
list.add(new BasicNameValuePair("password",""));
list.add(new BasicNameValuePair("utf-8",""));
list.add(new BasicNameValuePair("authenticity_token",getAuthenticityToken()));
list.add(new BasicNameValuePair("back_url",""));
list.add(new BasicNameValuePair("autologin",""));
HttpClient httpClient = HttpClients.createDefault();
httpPost.setEntity(new UrlEncodedFormEntity(list));
HttpResponse response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
String result = EntityUtils.toString(entity,"utf-8");
System.out.println(result);
return true;
}
其中httpClient和httpCore JAR包均为4.4.1版本