java - ReSTLet 默认路由?

标签 java restlet

我正在尝试使用 ReSTLet 框架设置几条路由,但我似乎不知道如何设置“默认路由”。

我尝试过这个:

@Override
public Restlet createInboundRoot() {
    Router router = new Router( getContext() );

    router.attach( "http://localhost:8111/", TestActionResource.class );
    router.attach( "http://localhost:8111/echo", EchoResource.class );

    router.setDefaultRoute( router.getRoutes().get( 0 ) );

    return router;
}

但是当我尝试类似的事情时:

http://localhost:8111/something

我收到“未找到”错误消息。

是否有一种简单的方法可以将未从路由器找到的页面设置为默认页面?

谢谢。

最佳答案

我差点就拥有了,就是这个:

@Override
public Restlet createInboundRoot() {
    Router router = new Router( getContext() );

    router.attachDefault( TestActionResource.class );
    router.attach( "http://localhost:8111/echo", EchoResource.class );

    return router;
}

关于java - ReSTLet 默认路由?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6259680/

相关文章:

java - 从 Eclipse 项目读取文件

java - 向 JTextArea 添加 double ?

java - 如何打包我的 Android ReSTLet 服务器所需的静态文件?

rest - 如何使用 JAXRS 和 JAXB 设置 ReSTLet 服务器?

java - 在 java :comp/env on Tomcat? 之外查找 JNDI 名称

java - 使用 jlabel 上的 imageicon 自动调整图像大小

java - 从 reSTLet 中检索参数

java - 使用 Ajax 和 java ReSTLet 在客户端应用程序中流式传输视频

java - 当 oneToMany 关系包含使用 Hibernate 过滤器的值时如何获取实体

java - 创建 ReSTLet Authorizer 以进行细粒度授权