判断是否是移动端

1.获取到用户的操作系统,客户端不同的版本


String userAgent=request.getHeader("user-Agent");
UserAgent ua = UserAgentUtil.parse(uaStr);
ua.getBrowser().toString();//Chrome
ua.getVersion();//14.0.835.163
ua.getEngine().toString();//Webkit
ua.getEngineVersion();//535.1
ua.getOs().toString();//Windows 7
ua.getPlatform().toString();//Windows

判断是否是移动端

ua.isMobile();
        String userAgent=request.getHeader("user-Agent");
        UserAgent ua = UserAgentUtil.parse(userAgent);

        System.out.println(ua.getBrowser().toString());
        System.out.println(ua.getVersion());
        System.out.println(ua.getEngine().toString());
        System.out.println(ua.getEngineVersion());
        System.out.println(ua.getOs().toString());
        System.out.println(ua.getPlatform().toString());

        if (ua.isMobile()) {
            System.out.println("移动端登录");
        }else{
            System.out.println( "PC端登录");
        }
        System.out.println("---------------");

        /*
        *
        * 火狐浏览器
        *
Firefox
60.0
Gecko
20100101
Linux
Linux
PC端登录
        *
        *
google 浏览器
Chrome
84.0.4147.135
Webkit
537.36
Linux
Linux
PC端登录

*

ipad
*
Safari
14.0
Webkit
605.1.15
OSX
Mac
PC端登录
*
*
posted @ 2020-09-30 10:15  Tony小哥  阅读(590)  评论(0编辑  收藏  举报