goja-web/src/main/java/goja/mvc/kits/Requests.java
public static String browserInfo(HttpServletRequest req) {
        String browserInfo = "other";
        String ua = req.getHeader("User-Agent").toLowerCase();
        String s;
        String version;
        String msieP = "msie ([\\d.]+)";
        String ieheighP = "rv:([\\d.]+)";
        String firefoxP = "firefox\\/([\\d.]+)";
        String chromeP = "chrome\\/([\\d.]+)";
        String operaP = "opr.([\\d.]+)";
        String safariP = "version\\/([\\d.]+).*safari";

        Pattern pattern = Pattern.compile(msieP);
        Matcher mat = pattern.matcher(ua);
        if (mat.find()) {
            s = mat.group();
            if (s != null) {
                version = s.split(" ")[1];
                browserInfo = "ie " + version.substring(0, version.indexOf("."));
                return browserInfo;
            }
        }

        pattern = Pattern.compile(firefoxP);
        mat = pattern.matcher(ua);
        if (mat.find()) {
            s = mat.group();
            if (s != null) {
                version = s.split("/")[1];
                browserInfo = "firefox " + version.substring(0, version.indexOf("."));
                return browserInfo;
            }
        }

        pattern = Pattern.compile(ieheighP);
        mat = pattern.matcher(ua);
        if (mat.find()) {
            s = mat.group();
            if (s != null) {
                version = s.split(":")[1];
                browserInfo = "ie " + version.substring(0, version.indexOf("."));
                return browserInfo;
            }
        }

        pattern = Pattern.compile(operaP);
        mat = pattern.matcher(ua);
        if (mat.find()) {
            s = mat.group();
            if (s != null) {
                version = s.split("/")[1];
                browserInfo = "opera " + version.substring(0, version.indexOf("."));
                return browserInfo;
            }
        }

        pattern = Pattern.compile(chromeP);
        mat = pattern.matcher(ua);
        if (mat.find()) {
            s = mat.group();
            if (s != null) {
                version = s.split("/")[1];
                browserInfo = "chrome " + version.substring(0, version.indexOf("."));
                return browserInfo;
            }
        }

        pattern = Pattern.compile(safariP);
        mat = pattern.matcher(ua);
        if (mat.find()) {
            s = mat.group();
            if (s != null) {
                version = s.split("/")[1].split(" ")[0];
                browserInfo = "safari " + version.substring(0, version.indexOf("."));
                return browserInfo;
            }
        }
        return browserInfo;
    }
public static String browserInfo(HttpServletRequest req) {
        String browserInfo = "other";
        String ua = req.getHeader("User-Agent").toLowerCase();
        String s;
        String version;
        String msieP = "msie ([\\d.]+)";
        String ieheighP = "rv:([\\d.]+)";
        String firefoxP = "firefox\\/([\\d.]+)";
        String chromeP = "chrome\\/([\\d.]+)";
        String operaP = "opr.([\\d.]+)";
        String safariP = "version\\/([\\d.]+).*safari";

        Pattern pattern = Pattern.compile(msieP);
        Matcher mat = pattern.matcher(ua);
        if (mat.find()) {
            s = mat.group();
            if (s != null) {
                version = s.split(" ")[1];
                browserInfo = "ie " + version.substring(0, version.indexOf("."));
                return browserInfo;
            }
        }

        pattern = Pattern.compile(firefoxP);
        mat = pattern.matcher(ua);
        if (mat.find()) {
            s = mat.group();
            if (s != null) {
                version = s.split("/")[1];
                browserInfo = "firefox " + version.substring(0, version.indexOf("."));
                return browserInfo;
            }
        }

        pattern = Pattern.compile(ieheighP);
        mat = pattern.matcher(ua);
        if (mat.find()) {
            s = mat.group();
            if (s != null) {
                version = s.split(":")[1];
                browserInfo = "ie " + version.substring(0, version.indexOf("."));
                return browserInfo;
            }
        }

        pattern = Pattern.compile(operaP);
        mat = pattern.matcher(ua);
        if (mat.find()) {
            s = mat.group();
            if (s != null) {
                version = s.split("/")[1];
                browserInfo = "opera " + version.substring(0, version.indexOf("."));
                return browserInfo;
            }
        }

        pattern = Pattern.compile(chromeP);
        mat = pattern.matcher(ua);
        if (mat.find()) {
            s = mat.group();
            if (s != null) {
                version = s.split("/")[1];
                browserInfo = "chrome " + version.substring(0, version.indexOf("."));
                return browserInfo;
            }
        }

        pattern = Pattern.compile(safariP);
        mat = pattern.matcher(ua);
        if (mat.find()) {
            s = mat.group();
            if (s != null) {
                version = s.split("/")[1].split(" ")[0];
                browserInfo = "safari " + version.substring(0, version.indexOf("."));
                return browserInfo;
            }
        }
        return browserInfo;
    }
获取客户端浏览器信息

@return string