java Gwt如何从响应中获取信息
我对解析xml包以获取一些信息的更好方法有疑问
首先,这是我从服务器得到的html响应:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 404 Invalid SID.</title>
</head>
<body>
<h2>HTTP ERROR: 404</h2>
<p>Problem accessing /http-bind/. Reason:
<pre> Invalid SID.</pre></p>
<hr /><i><small>Powered by Jetty://</small></i>
</body>
</html>
这是我发送无效帧时的openfire响应。所以我需要确保这个状态包含字符序列无效的SID
这是我的代码: res是object class=com。谷歌。gwt。http。客户回应
if (res.getStatusCode() != Response.SC_OK){
final XMLPacket resXML = XMLBuilder.fromXML(res.getText());
if (resXML != null && resXML.getFirstChild("head") != null) {
for (XMLPacket subPacket : resXML.getChildren("head")) {
if (subPacket.toString().toUpperCase().contains("INVALID SID")) {
Log.debug("HURRA SUCCESS");
}
}
}
}
但我不认为这是最好的方法。 我使用的是GWT2.5。所以我的问题是,有更好的方法使用gwt从html请求中获取信息吗
共 (0) 个答案