Restlet (Google アプリ エンジンのバージョン 2.0) でコンテンツ タイプをどのように設定しますか? この場合、コンテンツ タイプを「text/xml」に設定したいと思います。
私は持っている:
public class SubResource extends ServerResource {
@Get
public Representation get(Representation representation){
setStatus(Status.SUCCESS_OK);
StringRepresentation sr = new StringRepresentation(getSomeXml());
return sr;
}
}
Representation で設定された値なのか、リターン コードと同じように ServerResource クラスから設定された値なのかはわかりません。
答え:
StringRepresentation sr = new StringRepresentation(getSomeXml());
sr.setMediaType(MediaType.TEXT_XML);