且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从请求中获取 MediaType

更新时间:2023-02-17 11:40:16

Restlet 根据 Content-Type 标头获取请求的媒体类型.要值,可以用这个:

Restlet get the media type of the request based on the Content-Type header. To the value, you can use this:

MediaType mediaType = getRequest().getEntity().getMediaType();

ClientInfo 的媒体类型提示对应于 Accept 标头中提供的内容:

The media type hints of the ClientInfo corresponds to what is provided within the Accept header:

getRequest().getClientInfo().getAcceptedMediaTypes();

要获取 Restlet API 中标头的映射,您可以查看此链接:

To get the mapping of headers in the Restlet API, you could have a look at this link: