Java 如何在分层URI中检索属性?
使用Restlet,如何检索URL中传递的属性 例如: 在这里,我想检索123值 我正在使用下一组代码行:Java 如何在分层URI中检索属性?,java,google-app-engine,url-rewriting,restlet,Java,Google App Engine,Url Rewriting,Restlet,使用Restlet,如何检索URL中传递的属性 例如: 在这里,我想检索123值 我正在使用下一组代码行: router.attach("contacts/{contact_id}", ContactResource.class); public class ContactResource extends ServerResource { @Get public ContactDetail retrieve() { //how to retrieve the con
router.attach("contacts/{contact_id}", ContactResource.class);
public class ContactResource extends ServerResource
{
@Get
public ContactDetail retrieve()
{
//how to retrieve the contact_id value?
return null;
}
}
我上次使用Restlet已经有一段时间了,但如果我没记错的话,这应该可以:
int contact_id = Integer.parseInt(getRequest().getAttributes().get("contact_id"));
编辑: