1

举个例子。

我有资源

public class HelloWorldResource extends ServerResource {

    @Get
    public String represent(String arg) {
        return "hello, world (from the cloud!)" + arg;
    }


}

这是由

router.attach("/hi/{message}", HelloWorldResource.class);

是否可以配置路由,以便访问 /hi/somestuffhere 将使 restlet 在表示方法中填充 arg 参数?

4

1 回答 1

2

尝试这个: String msg = (String) getRequest().getAttributes().get("message");

您可以将它放在重写的 doInit() 方法中,以便让您对该资源的所有请求自动发生这种情况。

于 2010-04-19T16:12:01.620 回答