try {
URL url = new URL("http://192.168.0.111:8081/webserver/security/machinelist");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty("Cookie","JSESSIONID="+UserService.sessionID); //设置sessionID方法
conn.setReadTimeout(5000);
conn.setRequestMethod("GET");
System.out.println(conn.getResponseCode());
if (200 == conn.getResponseCode())
{
//获取输入流
InputStream is = conn.getInputStream();
ToolsHandler toolsHandler=new ToolsHandler();
byte[] data=toolsHandler.InputStreamToByte(is);
json=new String(data);
System.out.println("JASON");
System.out.println(json);
// json="{'MachineID':'123','state':'true','error':'1'}";
machines =getGson().fromJson(json, new TypeToken<List<Machine>>() {}.getType());
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("查询完了"+machines);
return machines;
URL url = new URL("http://192.168.0.111:8081/webserver/security/machinelist");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty("Cookie","JSESSIONID="+UserService.sessionID); //设置sessionID方法
conn.setReadTimeout(5000);
conn.setRequestMethod("GET");
System.out.println(conn.getResponseCode());
if (200 == conn.getResponseCode())
{
//获取输入流
InputStream is = conn.getInputStream();
ToolsHandler toolsHandler=new ToolsHandler();
byte[] data=toolsHandler.InputStreamToByte(is);
json=new String(data);
System.out.println("JASON");
System.out.println(json);
// json="{'MachineID':'123','state':'true','error':'1'}";
machines =getGson().fromJson(json, new TypeToken<List<Machine>>() {}.getType());
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("查询完了"+machines);
return machines;