关于URLconnection问题

qq_24642453 2017-04-24 06:11:21
下面一段代码
先建立了一次可靠连接,然后又进行了一次请求连接,这两次连接是否相互关联,如果这是两个互相独立的连接,怎样才能让第二请求并入第一次连接
//第一次连接
URL url = new URL("http://xxxx.xxxx.xx.cn/login.do");
URLConnection connection = url.openConnection();
// 设置通用的请求属性
connection.setRequestProperty("accept", "*/*");
connection.setRequestProperty("connection", "Keep-Alive");
connection.setRequestProperty("user-agent",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
connection.setUseCaches(true);
connection.setDoInput(true);
connection.setDoOutput(true);
// 建立实际的连接
connection.connect();
//第二次连接
ImageIcon newicon = new ImageIcon(new URL("http://xxxx.xxxx.xx.cn/getRandomImage.do?"+new Date()));
...全文
109 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_24642453 2017-04-24
  • 打赏
  • 举报
回复
有人吗,快来回答,快来

5,658

社区成员

发帖
与我相关
我的任务
社区描述
Web开发应用服务器相关讨论专区
社区管理员
  • 应用服务器社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧