【问题标题】:RESTLET-HELLO WORLD in GWTGWT 中的 RESTLET-HELLO WORLD
【发布时间】:2012-01-21 14:35:13
【问题描述】:

我在 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();
    }

}

【问题讨论】:

    标签: gwt restlet-2.0


    【解决方案1】:

    "没有可用的服务器连接器支持所需的协议:'HTTP' .请将匹配连接器的 JAR 添加到您的类路径”

    确保您已将相关的 jar 文件添加到您的类路径中: 例如:GWT客户端只依赖GWT版本提供的核心Restlet JAR(org.restlet.jar)。另请参阅常见问题解答:What JAR files must I have in my classpath for a minimal application? 并查看此处给出的答案:No available client connector supports the required protocol: 'HTTP'

    【讨论】:

    • 是的,我已经添加了必要的jar文件,我正在使用restlet 2.0,它带有内置的HTTP客户端和服务器!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-09-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-04
    • 2014-10-15
    • 2023-04-11
    相关资源
    最近更新 更多