HttpClient client = new HttpClient();
PostMethod postMethod = new PostMethod("http://122.22.22.2:2222/Object/HrTms.do");
postMethod.setRequestHeader("Content-type",
"application/x-www-form-urlencoded; charset=UTF-8");
// 泛型List -> Json
java.lang.reflect.Type type = new com.google.gson.reflect.TypeToken<List<Tab_User>>() {
}.getType(); String json = gson.toJson(pageList, type);
_log.debug(serviceUrl + "发送 Hr Json:" + json);
postMethod.setRequestBody(new NameValuePair[] {
new NameValuePair("Type", "Hr"),
new NameValuePair("data", json)
});
int status = 0;在发送JSON比较大时,经常会出现一下异常:
[INFO ] [15:52:01] org.apache.commons.httpclient.HttpMethodDirector - I/O exception (org.apache.commons.httpclient.NoHttpResponseException) caught when processing request: The server 122.22.22.2:2222 failed to respond
[INFO ] [15:52:01] org.apache.commons.httpclient.HttpMethodDirector - Retrying request
[INFO ] [15:52:10] org.apache.commons.httpclient.HttpMethodDirector - I/O exception (java.net.ConnectException) caught when processing request: Connection timed out: connect
[INFO ] [15:52:10] org.apache.commons.httpclient.HttpMethodDirector - Retrying request这就是丢失包?有没有什么办法解决或者尽量减少这种问题?
解决方案 »
- 哪位大侠能指点下,java 静态分页 实现思路
- 分析applicationContext文件里面的配置
- 求助:spring3+hibernate注解dao为null
- 如何用struts1.2上传图片
- Strut2+hibernate3.3+Spring2.5老出现错误,请教高手!!急急?
- 大侠救急啊,电脑上装了oracle后的怪事情怎样解决啊?
- 我用tomcat做服务器,调试我自已的jsp文件,怎么出现这样的错误,请指教。。。谢谢
- 求教问题
- ejbcreate的时候出现out of memory exception
- idea 常用快捷键
- 这个代码中list.remove("Anhui ");有什么用?
- hibernate hql如何查询满足条件的第一条记录
HttpConnectionParams.setConnectionTimeout(params, 2000);
/* 读取超时 */
HttpConnectionParams.setSoTimeout(params, 4000);