我在 GWT 中使用 Restlet 开发了一个简单的 hello world 应用程序,但它让我失望了
“没有可用的客户端连接器支持所需的协议:'HTTP'”在客户端和服务器端
“没有可用的服务器连接器支持所需的协议:'HTTP'。请将匹配连接器的 JAR 添加到您的类路径中。”
这是我的 hello world 应用程序:
客户:
import org.restlet.resource.ClientResource;
public class HelloClient {
public static void main(String[] args) throws Exception {
ClientResource helloClientresource = new ClientResource(
"http://localhost:8111/");
helloClientresource.get().write(System.out);
}
}
服务器资源:
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
/**
* Simple "hello, world" server resource.
*/
public class HelloServerResource extends ServerResource {
@Get("txt")
public String represent() {
return "hello, world";
}
}
服务器:
import org.restlet.Server;
import org.restlet.data.Protocol;
public class HelloServer {
public static void main(String[] args) throws Exception {
Server helloServer = new Server(Protocol.HTTP, 8111,
HelloServerResource.class);
helloServer.start();
}
}