记录我在使用HttpClient在项目A中调项目B的接口遇见的问题

1.post方式提交时传参

method.setRequestBody(new NameValuePair[]{new NameValuePair(key, param)});

在使用post提交时,传参需要使用NameValuePair类。

2.乱码

class UTF8PostMethod extends PostMethod{

public UTF8PostMethod(String url){

super(url);

}

@Override

public String getRequestCharSet(){

   return "UTF-8";

}

}

你可能感兴趣的:(记录我在使用HttpClient在项目A中调项目B的接口遇见的问题)