0
我是新来的restlet,我想知道是否有方法来指定responseformat。如何选择响应格式与Restlet
在OData的你可以追加$格式= JSON或$格式=例如
http://services.odata.org/OData/OData.svc/Products?$格式的XML = JSON
在哪里或如何指定我的responstyp或格式的Restlet?
丹尼尔
我是新来的restlet,我想知道是否有方法来指定responseformat。如何选择响应格式与Restlet
在OData的你可以追加$格式= JSON或$格式=例如
http://services.odata.org/OData/OData.svc/Products?$格式的XML = JSON
在哪里或如何指定我的responstyp或格式的Restlet?
丹尼尔
您可以标注您的资源,指定表示:
// Returns a representation in the "text/xml" media type
@Get("xml")
String toString();
// Stores representations in the "text/xml" media type
// after conversion to a DOM document
@Put("xml")
void store(Document doc)
// Stores representations in the "text/xml" media type after
// conversion to a DOM document and returns a plain text response
@Put("xml:txt")
String store(Document doc)
// Returns a representation in the "text/xml" media type with
// an inlining depth level of 2
@Get("xml?depth=2")
// Alternative variants
@Put("xml|json:json")
// Alternative variants
@Put("xml+ascii | json+utf8 : json")
也看到Resource Package文档