Java 获取HTTPResponse实体
在服务器上执行get方法后,我试图从响应中获取html代码,当我试图解析实体时,我的代码就停止了。并且执行仅在“String loginResponseBody=EntityUtils.toString(响应)”行停止 .getEntity());” 这意味着什么?还有其他方法吗Java 获取HTTPResponse实体,java,html,httpclient,httpresponse,Java,Html,Httpclient,Httpresponse,在服务器上执行get方法后,我试图从响应中获取html代码,当我试图解析实体时,我的代码就停止了。并且执行仅在“String loginResponseBody=EntityUtils.toString(响应)”行停止 .getEntity());” 这意味着什么?还有其他方法吗 HttpResponse response = client.httpPost1(viewState, "http://syspower.skm.no/syspo
HttpResponse response = client.httpPost1(viewState,
"http://syspower.skm.no/syspower3/mobile/Login.aspx",
username, password);
System.out.println("got response");
System.out.println(response);
System.out.println(response.getStatusLine());
String loginResponseBody = EntityUtils.toString(response
.getEntity());
System.out.println(loginResponseBody);
String table = clearHTML(loginResponseBody);
System.out.println(table);
p.S.实体不为空,且同一部分代码在应用程序的其他部分中有效
p.p.S.这完全是我的错,开始不理解我自己的代码。。我应该在服务器上执行get函数后得到回复,因为在post之后,我一直(通过服务器)得到重定向。因此,最终版本如下:
String viewState = client
.httpGetViewstate("http://syspower.skm.no/syspower3/mobile/Login.aspx");
HttpResponse response = client.httpPost1(viewState,
"http://syspower.skm.no/syspower3/mobile/Login.aspx",
userPrefs.getUserName(), userPrefs.getUserPassword());
System.out.println("posted!");
String commentsHtml = client
.httpGet("http://syspower.skm.no/syspower3/mobile/PriceTables.aspx");
// System.out.println(commentsHtml);
if (commentsHtml.contains("table")) { //or better to do with the Jsoup to search for first table
success = true;
System.out.println("username is ok");
System.out.println(commentsHtml);
this.finish();
} else {
System.out.println("back again..");
fail = true;
loginBox();
}
状态行是怎么说的?有趣的是执行停止了,再也没有进展了。。我真的不知道