开发者

Does Restlet support parsing URLs into calling methods with parameters?

开发者 https://www.devze.com 2022-12-27 04:37 出处:网络
Take the following example. I have a resource public class HelloWorldResource extends ServerResource { @Get

Take the following example.

I have a resource

public class HelloWorldResource extends ServerResource {

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


}

That is mapped by

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

Is it possible to configure the routing su开发者_Go百科ch that accessing /hi/somestuffhere will make restlet fill in the arg parameter in the represent method?


Try this: String msg = (String) getRequest().getAttributes().get("message");

You can place this in an overriden doInit() method in order to let this happen automatically for all your requests to this resource.

0

精彩评论

暂无评论...
验证码 换一张
取 消