2011-09-13 5 views
1

Restlet을 사용하여 URL에 전달 된 속성을 검색하려면 어떻게해야합니까?계층 적 URI에서 속성을 검색하는 방법은 무엇입니까?

예 : http://localhost:8888/contacts/123

여기에, 나는 123 값을 검색합니다. 내가 마지막으로 Restlet을 사용하기 때문에

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; 
    } 
} 

답변

2

잠시 동안 이었지만, 내가 올바르게 기억이 작동합니다 :

I 라인 코드의 다음 세트를 사용하고

int contact_id = Integer.parseInt(getRequest().getAttributes().get("contact_id")); 

편집 : documentation on routing in Restlet 2.1

+0

감사합니다. 작동합니다! :) – Valdemar