解决方案 »
- 一个android4.0上widget的问题
- 安卓很多textview带来的问题
- 有一个关于“Android SAX解析XML”的问题
- 想买一个电脑,想买苹果,感觉不怎么适合编程,求介绍。。。
- webview载入页面和手机的网有关吗?在线等
- 大家平时单位都用px吗,还是in,mm,pt,dp,sp呢?
- 自己用CXF+spring+hibernate写了个简单的webservice,用android虚拟机连接老是报错
- 谁知道腾讯新闻里世界杯赛程魔方效果是如何实现的?
- 求助大神,安卓虚拟机数据库找不到文件
- 关于eclipse中的citl +H无结果
- android raw文件夹里的文件无法解析
- 新手求解android线程问题、望大神解答,不盛感激
除非你的代码调用有问题,或者你的请求放在了service里面,service重复执行导致的。
没有放service里,用的AsyncTask。看下下面的文章,说是jdk1.4.2的bug,但是我用的是1.6.6,谢谢
http://wenku.baidu.com/link?url=q_nrKoNNis8bTWNbcopGO0YGzmTKfZG_JVboTvSxg5dWfVaOp_W-lLlagVeNmsgSJAsZL_0dy_vKGRFlEPKUR5W2VfdLl6Sodhhtw1pRsmG
而且你还要看看你测试时android的版本
只有调一次,有打Log, android 4.3 sansung note3. 华为荣耀四核 android4.2都会出现这样的情况。
另外J2ME程序的nokia手机也会
Android我已经换成HttpClient,有设置HttpRequestRetryHandler为false,就不会出现重发的现象.
但是在j2me中只有HttpConnection,找不到问题可怎么办啊
以前在一个人的blog中看到的,现在找不到了
请问,这个有资料可查吗?如何能禁用呢?
以前在一个人的blog中看到的,现在找不到了麻烦帮忙找下,万分感谢。
请问,这个有资料可查吗?如何能禁用呢?
以前在一个人的blog中看到的,现在找不到了麻烦帮忙找下,万分感谢。原来那个找不到了 你看看这个 意思类似
http://blog.csdn.net/hanqunfeng/article/details/4510338
请问,这个有资料可查吗?如何能禁用呢?
以前在一个人的blog中看到的,现在找不到了麻烦帮忙找下,万分感谢。原来那个找不到了 你看看这个 意思类似
http://blog.csdn.net/hanqunfeng/article/details/4510338谢谢。但是他说是jdk1.4.2的bug,可是我用的是jdk1.6.0,还是会出现这个重发的问题
谢谢你的回复。看了上面的帖子,还是没得到有用的信息。下面我就贴出j2me的代码。
private class RunHttpRequest implements Runnable { private HttpConnection conn = null;
private OutputStream os = null;
private InputStream is = null;
private ByteArrayOutputStream baos = null;
private DataOutputStream dos = null; private String result;
private String url;
private String method;
private Vector ps; public RunHttpRequest(String url, String method, Vector ps) {
this.url = url;
this.method = method;
this.ps = ps;
} public void run() {
try { String sParam = "&m=" + method;
for (int i = 0; i < ps.size(); i++) {
sParam += "&p" + String.valueOf(i) + "=" + ps.elementAt(i).toString();
} conn = (HttpConnection) Connector.open(url, Connector.READ_WRITE);
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setRequestProperty("Content-Length", Integer.toString(sParam.length()));
conn.setRequestProperty("Charset", "utf-8");
conn.setRequestProperty("Connection", "Keep-Alive");
conn.setRequestProperty("Content-Language", "en-US");
conn.setRequestMethod(HttpConnection.POST); os = conn.openDataOutputStream();
//sParam = URLEncoder.encode(sParam,"UTF-8");
os.write(sParam.getBytes());
os.flush(); int respCode = conn.getResponseCode();
if (respCode == HttpConnection.HTTP_OK) {
is = conn.openDataInputStream();
int contentLen = (int)conn.getLength();
if(contentLen>0){
byte[] b = new byte[contentLen];
int len = 0;
baos = new ByteArrayOutputStream();
dos = new DataOutputStream(baos);
while ((len = is.read(b)) != -1) {
dos.write(b, 0, len);
} byte[] bytes = baos.toByteArray();
result = new String(bytes, "utf-8"); result = StringUtil.replaceString(result, "\r\n", "\n");
}
}
else if(respCode == HttpConnection.HTTP_MOVED_TEMP){
//当用户从其它地方登录时,服务器URL发生转向.
result = HTTP_RESULT_MOVED_TEMP;
}
else {
result = HTTP_RESULT_SERVER_ERROR;
}
}
catch (Exception e) {
result = HTTP_RESULT_EXCEPTION;
MainMidlet.perferences.setRecord_Log(CommonData.KEY_LOGINFO,("Exception-"+e.getMessage()).getBytes());
}
finally {
close();
}
} /**
* @return the result
*/
public String getResult() {
return result;
} public void close() {
try {
if (conn != null) {
conn.close();
conn = null;
}
if (os!=null){
os.close();
os = null;
}
if (is != null) {
is.close();
is = null;
}
if (baos != null) {
baos.close();
baos = null;
}
if (dos != null) {
dos.close();
dos = null;
}
}
catch (IOException ex) {
ex.printStackTrace();
}
}
}
2 你看下能否查看源代码,然后找到这个重发的相关设置的位置,利用java反射机制关掉它。
http://bugs.java.com/view_bug.do?bug_id=6672144这里面描述的 bug 和你说的很像。它的解决方案是设置系统属性。
From JDK6 you can set the system property, sun.net.http.retryPost, to false to prevent the HTTP client from silently resending the POST request.
java -Dsun.net.http.retryPost=false ...2:
http://developer.nokia.com/community/discussion/showthread.php/233689-HTTP-Connection-sending-request-twice-after-30-sec这个完全是你说的案例。它的建议是后台参与进来
请问,这个有资料可查吗?如何能禁用呢?
以前在一个人的blog中看到的,现在找不到了麻烦帮忙找下,万分感谢。原来那个找不到了 你看看这个 意思类似
http://blog.csdn.net/hanqunfeng/article/details/4510338谢谢。但是他说是jdk1.4.2的bug,可是我用的是jdk1.6.0,还是会出现这个重发的问题
你应该试下jdk 1.7 如果1.7没有这个现象 那就是jdk1.6也存在这个bug 如果jdk1.7不存在这个问题 那就是你自己代码问题
这2者不一致有关系吗?如果连接还没有超时,而读取时间超时的话,HttpUrlConnection就会再重新发送请求。所以,要解决这个重发问题,可以试一下,把读取超时的时间设置得比连接超时稍长一点,因为有时候,jdk计算的时间会有点偏差,这样可以保证在连接超时之前不会读取超时