사실 올바른 방법이 있지만 MediaType
(new MediaType(name, description)
) 클래스의 올바른 생성자를 사용하지 마십시오.
당신의 코드가 작동하려면이로 변경해야합니다
resource.get(new MediaType("application/user+yml"));
를 서버 측에서, 당신이 얻을 것이다 :
@Get
public Representation getSomething() {
System.out.println(">> media types = " +
getRequest().getClientInfo().getAcceptedMediaTypes());
// Display this: media types = [application/user+yml:1.0]
(...)
}
당신은으로 Restlet의 연장 지원을 활용할 수 있습니다 특수 효과 내에서 값을 추가하여 Get
.
public class MyApplication extends Application {
public MyApplication() {
getMetadataService().addExtension(
"myextension", new MediaType("application/user+yml"));
(...)
}
@Override
public Restlet createInboundRoot() {
(...)
}
}
지금 당신은 당신의 서버 리소스 내에서 확장을 사용할 수 있습니다 : 아래와 같이 귀하의 경우에는 사용자 지정 확장을 추가 할 필요가
이 방법은 예상되는 미디어 타입에 사용됩니다
@Get("myextension")
public Representation getSomething() {
(...)
}
application/user+yml
입니다.
희망 하시겠습니까? Thierry