HttpClient的使用(5)
来源:未知 责任编辑:责任编辑 发表时间:2014-04-20 03:36 点击:次
responseText = getMethod.getResponseBodyAsString();
} catch (HttpException e) {
StringBuilder sb = new StringBuilder("HttpException occured when getQuestionaire, requestUrl=");
sb.append(feedBackQuestionaireUrl).append("?id=").append(id);
log.error(sb.toString(), e);
return null;
} catch (IOException e) {
StringBuilder sb = new StringBuilder("IOException occured when getQuestionaire, requestUrl=");
sb.append(feedBackQuestionaireUrl).append("?id=").append(id);
log.error(sb.toString(), e);
return null;
} finally {
getMethod.releaseConnection();
getMethod = null;
}
if (StringUtil.isBlank(responseText)) {
return null;
}
// 从查询结果中解析出包含问卷的json字符串
int index = responseText.indexOf("=");
if (index >= 0) {
responseText = responseText.substring(index + 1);
}
try {
JSONObject json = JSONObject.fromObject(responseText);
return json;
} catch (Exception e) {
log.error("fail to change from String to JSONObject, string=" + responseText, e);
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>