public static String doPostOtherBody(String url, Map<String, Object> params,HashMap<String, String> headParams){
String response = "";
StringBuffer strtTotalURL = new StringBuffer();
if(url.indexOf("?") == -1) {
strtTotalURL.append(url).append("?").append(URLUtil.buildQuery(params, CharsetUtil.CHARSET_UTF_8));
} else {
strtTotalURL.append(url).append("&").append(URLUtil.buildQuery(params, CharsetUtil.CHARSET_UTF_8));
}
url= strtTotalURL.toString();
System.out.println("url---------"+url);
try {
headParams.put("Content-Type","application/x-www-form-urlencoded");
// response = HttpUtil.post(url, method,10000);
response = HttpRequest.post(url).addHeaders(headParams)//头信息,多个头信息多次调用此方法即可
.form(params)
// .body(JSONUtil.toJsonStr(params))//表单内容
.setConnectionTimeout(10000)//超时,毫秒
.setReadTimeout(600000)
.execute().body();
}catch(Exception e){
logger.error("发生异常", e);
e.printStackTrace();
response = null;
}finally {
return String.valueOf(response);
}
}