postMethod 返回值不全问题求助
引入的包是:commons-codec-1.5.jar、commons-httpclient-3.0.1.jar、httpcore-4.2.4.jar
HttpClient client = new HttpClient();
String url="http://localhost:8089/public/getNameLists?entpName="+entpName+ "&orgCode=" +orgCode+ "&typeCode=" +typeCode+ "";
System.out.println("连接的url数据:"+url);
client.getHttpConnectionManager().getParams().setConnectionTimeout(5000); //连接超时为5秒
client.getHttpConnectionManager().getParams().setSoTimeout(5000); //读取超时
PostMethod postMethod = new PostMethod(url);
postMethod.setRequestHeader("Content-Type", "application/json");
//设置参数编码为utf-8
postMethod.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET,"utf-8");
try {
//读取内容
int status = client.executeMethod(postMethod);
if (postMethod.getStatusCode() == HttpStatus.SC_OK) {
BufferedReader reader = new BufferedReader(new InputStreamReader(postMethod.getResponseBodyAsStream()));
StringBuffer stringBuffer = new StringBuffer();
String str = "";
while((str = reader.readLine())!=null){
stringBuffer.append(str);
}
String html=stringBuffer.toString();
System.out.println("返回来的数据:"+html);
}
} catch (Exception e) {
e.printStackTrace();
}finally{
//释放连接
postMethod.releaseConnection();
}
打印结果:返回来的数据:{"result":"1","tableName":"重大税收违法案件,"}
正确的结果:{"result":"1","tableName":"重大税收违法案件,工商吊销企业名单,"} tableName中缺少一个值,请问是怎么回事儿,因为项目中好多地方都用了这个包,所以不想换掉,请问如果不更换jar包 还有没有别的解决办法。。