SDProgrammer 2015-11-26 10:51 采纳率: 0%
浏览 1716

关于用http client模拟登录教务系统的问题 跪求大神指点!

response = httpclient.execute(httppost,context);
String result = response.getStatusLine().toString();
System.out.println(result);
HttpEntity entity1 = response.getEntity();
System.out.println(EntityUtils.toString(entity1));
Header locationHeader =response.getFirstHeader("location");

System.out.println(locationHeader.toString());

             String newuri = "http://jwxt1.cumt.edu.cn"+locationHeader.getValue(); 


         System.out.println(result);     
            HttpGet redirect=new HttpGet(newuri);  

            CloseableHttpResponse response1=httpclient.execute(redirect,context);  
            HttpEntity entity = response1.getEntity();
              System.out.println(EntityUtils.toString(entity)); 


            redirect.releaseConnection();  

返回的结果```
HTTP/1.1 302 Moved Temporarily

Object moved

Object moved to here.

Location: /xs_main.aspx?xh=我的学号

用httpclient模拟登陆学校的方正教务系统 post数据以后再获取重定向的地址进行get访问 为何不行


  • 写回答

4条回答 默认 最新

  • 花前月下的细说 2015-11-26 11:29
    关注

    可以试着用OKhttp试一下

    评论

报告相同问题?

悬赏问题

  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64