java 获取浏览器类型_JAVA_编程开发_程序员俱乐部
java 获取浏览器类型
- 摘要:publicStringgetBrowserType(HttpServletRequestrequest){Stringtype="ie";StringbrowserName=request.getHeader("USER-AGENT").toLowerCase();if(browserName.indexOf("msie")>0){type="ie";}if(browserName.indexOf("firefox")>0){type="firefox";}if
- 标签:浏览 Java 浏览器
public String getBrowserType(HttpServletRequest request)
{
String type = "ie";
String browserName = request.getHeader("USER-AGENT").toLowerCase();
if (browserName.indexOf("msie") > 0) {
type = "ie";
}
if (browserName.indexOf("firefox") > 0) {
type = "firefox";
}
if (browserName.indexOf("chrome") > 0) {
type = "chrome";
}
if (browserName.indexOf("opera") > 0) {
type = "opera";
}
if(browserName.indexOf("gecko")>0 && browserName.indexOf("rv:11")>0){
type="ie11";
}
return type;
}