一个好用的rest 请求工具包

org.restlet-2.0.0 2.jar


public static void testGet() {
		ClientResource client = new ClientResource(url);
		try {
			System.out.println(client.get().getText());
		} catch (ResourceException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

public static void testPost() {
		ClientResource client = new ClientResource(url);
		try {
			String message = client.post(postContent).getText();
			System.out.println(message);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static void testPut() {
		ClientResource client = new ClientResource(url);
		try {
			String message = client.put(putContent).getText();
			System.out.println(message);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}


你可能感兴趣的:(REST)