browser version detection from server side with java

大城市里の小女人 提交于 2019-12-08 23:56:29

问题


I saw many posts related to the browser detection, User agent detection etc...I want to detect the version from server side and send appropriate data based on that.

I know browsers can mimic version with tools, but that doesn't matter for me.

I need the java solution for the exact version detection.


回答1:


Take a look at user-agent-utils.




回答2:


Here is the code explaining how to do it using user-agent-utils:

String userAgent = req.getHeader("user-agent");
UserAgent ua = UserAgent.parseUserAgentString(userAgent);
Version browserVersion = ua.getBrowserVersion();
String browserName = ua.getBrowser().toString();
int majVersion = Integer.parseInt(browserVersion.getMajorVersion());



回答3:


Check the headers in the HTTP servlet request - they'll tell you. Check the "User-Agent" header.




回答4:


I recommend UA Detector at uadetector.sourceforge.net




回答5:


Use Spring Mobile Device Module?

This can use either the LiteDeviceResolver or the WurflDeviceResolver.



来源:https://stackoverflow.com/questions/7469159/browser-version-detection-from-server-side-with-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!