/** * 判断请求是否手机端 * @param req * @return */ public static boolean isMobile(HttpServletRequest req) { UserAgent ua = UserAgent.parseUserAgentString(req.getHeader("User-Agent")); OperatingSystem os = ua.getOperatingSystem(); if(DeviceType.MOBILE.equals(os.getDeviceType())) { return true; } return false; }