httpClient session保持问题,登陆后,再次提交表单出现返回到登陆页面

DefaultHttpClient client = new DefaultHttpClient(new ThreadSafeClientConnManager());
//登陆参数代码省略

int statuscode = httpresponse.getStatusLine().getStatusCode();/* 登录状态返回 */
			CookieStore cookiestore=client.getCookieStore();
List<Cookie> cookies = client.getCookieStore().getCookies();
			if (cookies.isEmpty()) {
				throw new BusiException("智联招聘 登录失败,请检查用户名、密码及验证码!");
			} else {
				/* 处理重链接 */
				if ((statuscode == HttpStatus.SC_MOVED_TEMPORARILY)
						|| (statuscode == HttpStatus.SC_MOVED_PERMANENTLY)
						|| (statuscode == HttpStatus.SC_SEE_OTHER)
						|| (statuscode == HttpStatus.SC_TEMPORARY_REDIRECT)) {
					HttpEntity entity = httpresponse.getEntity();
					//String body = EntityUtils.toString(entity);
					/*String newUrl=HttpClientService.getNewUrl(httpresponse);重连接地址获取homePage.asp*/
					/*跳转到职位发布页面http://rd2.zhaopin.com/s/vacainfo/PositionAdd.asp 并发布职位*/
					HttpResponse httpDoVacancyResponse = HttpClientService.doHttpPost(client,
							"http://rd2.zhaopin.com/s/vacainfo/PositionAddPost.asp", this.doZhiLianData(dsZhiLian), code,cookiestore);
					int doVacancyStatusCode = httpDoVacancyResponse.getStatusLine().getStatusCode();
					HttpEntity doVacancyEntity = httpDoVacancyResponse.getEntity();
					String doVacancybody = EntityUtils.toString(doVacancyEntity);
					String newUrl=HttpClientService.getNewUrl(httpDoVacancyResponse);
					if(newUrl.indexOf("PositionCheck.asp")<0)
						new Exception("提交职位信息出现错误。"); 
					Log.info(doVacancybody);
				}
			}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值