哪些Java库执行HTTP Accept Header Parsing?

哪些Java库解析HTTP Accept标头?

看看HttpClient Util.parseHeader方法。


编辑:(试图让这个答案值得在事后接受)

spring框架在其MediaType组件中提供此function。

如果您已经在使用Spring MVC,则可以简单地请求HttpHeaders类型的@RequestHeader -annotated参数,并通过简单地调用HttpHeaders.getAccept()来访问接受的媒体类型列表。

您应该阅读这篇文章: 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, Java中的 mime类型的基本函数

根据主页:

 List mimeTypesSupported = Arrays.asList(StringUtils.split( "application/xbel+xml,text/xml", ',')); String bestMatch = MIMEParse.bestMatch(mimeTypesSupported, "text/*;q=0.5,*/*;q=0.1");