String url = "http://120.25.102.84:8000/creditAudit";
PostMethod postMethod = new PostMethod(url);
// 填入各个表单域的值
NameValuePair[] data = {
new NameValuePair("message", JSON.toJSONString(ll))};
System.out.println("推送成功");
// 将表单的值放入postMethod中 commons-httpclient.jar
postMethod.setRequestBody(data);
postMethod.getParams().setContentCharset("utf-8");
postMethod.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET,"utf-8");
// 执行postMethod
int statusCode = 0;
try {
statusCode = new HttpClient().executeMethod(postMethod);
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
// HttpClient对于要求接受后继服务的请求,象POST和PUT等不能自动处理转发
// 301或者302
if (statusCode == HttpStatus.SC_MOVED_PERMANENTLY
|| statusCode == HttpStatus.SC_MOVED_TEMPORARILY) {
// 从头中取出转向的地址
Header locationHeader = postMethod.getResponseHeader("location");
String location = null;
if (locationHeader != null) {
location = locationHeader.getValue();
System.out.println("diandianLogin:" + location);
} else {
System.err.println("Location field value is null.");
}
return;
} else {
System.out.println(postMethod.getStatusLine());
String str = "";
try {
str = postMethod.getResponseBodyAsString();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(str);
}
postMethod.releaseConnection();
return;
new NameValuePair("message", JSON.toJSONString(ll))}; messages是个list 但是转成json 但是 格式如下
[name=message, value=[{"BAL":"5273.84","BILLDTLS_ID":"AazLIsjsMYnlKYirmNOx","LOANID":"NJGL20160428002","PRERETUAMT":"3052.40"}]]
单我想 修改格式为:
[{"BAL":"5273.84","BILLDTLS_ID":"AazLIsjsMYnlKYirmNOx","LOANID":"NJGL20160428002","PRERETUAMT":"3052.40"}]
请问如何修改,大神勿喷