[英]Unable to get `User-Agent` properly from header
`Hi, 嗨,
I am trying to get the user's browser information in my servlet filter. 我试图在我的servlet过滤器中获取用户的浏览器信息。 I used a simple code, see below.
我使用了一个简单的代码,请参见下文。
String userAgent = request.getHeader("User-Agent");
User was using Google chrome, and what the above code printed is below. 用户正在使用Google chrome,上面打印的代码如下。
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36
It printed the names of all the major browsers instead of getting the once the app is running. 它会打印所有主要浏览器的名称,而不是在应用程序运行后立即显示。 what is wrong here?
这是怎么了
Nothing is wrong here. 这里没事。
For example let us consider the returned string is 例如,让我们考虑返回的字符串是
Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36 Mozilla / 5.0(Windows NT 6.1)AppleWebKit / 537.36(KHTML,例如Gecko)Chrome / 41.0.2228.0 Safari / 537.36
Then the explanation is 然后的解释是
ChromeChrome 41.0.2228.0
Mozilla ==>
MozillaProductSlice. Claims to be a Mozilla based user agent, which is only true for Gecko browsers like Firefox and Netscape. For all other user agents it means 'Mozilla-compatible'. In modern browsers, this is only used for historical reasons. It has no real meaning anymore
5.0 ==> Mozilla version
Windows NT 6.1 ==> Operating System Windows 7
AppleWebKit ==> The Web Kit provides a set of core classes to display web content in windows
537.36 ==> Web Kit build
KHTML ==> Open Source HTML layout engine developed by the KDE project
like Gecko ==> like Gecko...
Chrome Name ==> Chrome
41.0.2228.0 ==> Chrome version
Safari ==> Based on Safari
537.36 ==> Safari build
Description: Free open-source web browser developed by Google.
Chromium is the name of the open source project behind Google Chrome, released under the BSD license.
You can find more information in below link 您可以在下面的链接中找到更多信息
http://www.useragentstring.com/pages/Chrome/ http://www.useragentstring.com/pages/Chrome/
click on each link on the page to get more info 单击页面上的每个链接以获取更多信息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.