java - 如何检索分层 URI 中的属性?

标签 java google-app-engine url-rewriting restlet

使用ReSTLet,如何检索URL中传递的属性?

示例:http://localhost:8888/contacts/123

在这里,我想检索 123 值。

我正在使用下一组行代码:

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"));

编辑:documentation on routing in Restlet 2.1

关于java - 如何检索分层 URI 中的属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7400996/

相关文章:

java - 计算代码行数 - 质量指标

python - "TypeError: object of type ' NoneType ' has no len()"登录Webapp2 Auth示例代码后

php - 将带有文件夹的 php url 映射到查询字符串

java - 实例变量为 null 时抛出的异常

java - 为什么Java中HashSet不按65535排序?

java - Android 应用程序设置未显示

ruby-on-rails - 如何在 appengine 上迁移 Datamapper

java - 对端点使用 Auth

nginx - 如何首先将 nginx 配置为 try_files,如果不存在则遵循 request_uri

php - 基于 MVC 基础的动态路由 - i18n 和 l10n