Unirest-拼装http请求发送rest接口
public static Integer getInfo(String name) {
HttpResponse<Integer> httpResponse = null;
try {
httpResponse = Unirest.get(url) //url网址
.queryString("sn", serialNumber) //查询参数
.asObject(Integer.class); //返回类型
} catch (UnirestException e) {
logger.error(e.getMessage());
return null;
}
if (null == httpResponse || 200 != httpResponse.getStatus()) {
return null;
}
return httpResponse.getBody();
}