哪些Java库可以解析HTTP Accept
头?
发布于 2011-10-10 03:32:13
看一看HttpClient Util.parseHeader
方法。
编辑:(试图让这个答案值得在事后被接受)
spring框架在其MediaType组件中提供了此功能。
如果您已经在使用Spring MVC,那么您可以简单地请求类型为HttpHeaders
的@RequestHeader
-annotated参数,并通过简单地调用HttpHeaders.getAccept()来访问可接受的媒体类型列表。
发布于 2011-10-10 03:32:04
你应该阅读这篇文章:http://www.xml.com/pub/a/2005/06/08/restful.html
这篇文章使用Python,但这不是问题:在最后,共享了以下链接:http://code.google.com/p/mimeparse
如您所见,"mimeparse“是:
用于在Erlang、JavaScript、Perl、PHP、Python、Ruby、
中处理mime类型的基本函数
根据主页:
List<String> mimeTypesSupported = Arrays.asList(StringUtils.split(
"application/xbel+xml,text/xml", ','));
String bestMatch = MIMEParse.bestMatch(mimeTypesSupported, "text/*;q=0.5,*/*;q=0.1");
https://stackoverflow.com/questions/7705979
复制相似问题