java web判断手机还是pc机访问
2011-11-17 09:22
316 查看
String userAgent=request.getHeader("user-agent"); if(userAgent!= null ){ userAgent = userAgent.toUpperCase(); } if (userAgent.indexOf("NOKI") > -1 || // Nokia phones and emulators userAgent.indexOf("ERIC") > -1 || // Ericsson WAP phones and emulators userAgent.indexOf("WAPI") > -1 || // Ericsson WapIDE 2.0 userAgent.indexOf("MC21") > -1 || // Ericsson MC218 userAgent.indexOf("AUR") > -1 || // Ericsson R320 userAgent.indexOf("R380") > -1 || // Ericsson R380 userAgent.indexOf("UP.B") > -1 || // UP.Browser userAgent.indexOf("WINW") > -1 || // WinWAP browser userAgent.indexOf("UPG1") > -1 || // UP.SDK 4.0 userAgent.indexOf("UPSI") > -1 || //another kind of UP.Browser userAgent.indexOf("QWAP") > -1 || // unknown QWAPPER browser userAgent.indexOf("JIGS") > -1 || // unknown JigSaw browser userAgent.indexOf("JAVA") > -1 || // unknown Java based browser userAgent.indexOf("ALCA") > -1 || // unknown Alcatel-BE3 browser (UP based) userAgent.indexOf("MITS") > -1 || // unknown Mitsubishi browser userAgent.indexOf("MOT-") > -1 || // unknown browser (UP based) userAgent.indexOf("MY S") > -1 || // unknown Ericsson devkit browser userAgent.indexOf("WAPJ") > -1 || //Virtual WAPJAG www.wapjag.de userAgent.indexOf("FETC") > -1 || //fetchpage.cgi Perl script from www.wapcab.de userAgent.indexOf("ALAV") > -1 || //yet another unknown UP based browser userAgent.indexOf("WAPA") > -1 || //another unknown browser (Web based "Wapalyzer") userAgent.indexOf("OPER") > -1 || //Opera userAgent.indexOf("DOPOD") > -1 || //多普达 userAgent.indexOf("SYMBIAN") > -1 //symbian系统 ) {//手机访问 }
Pattern pattern = Pattern.compile(";\\s?(\\S*?\\s?\\S*?)\\s?(Build)?/"); Matcher matcher = pattern.matcher(userAgent); String model = null; if (matcher.find()) { model = matcher.group(1).trim(); log.debug("通过userAgent解析出机型:" + model); }
转载:http://lianj-lee.iteye.com/blog/460226
相关文章推荐
- 判断访问来源是手机还是电脑
- 前端js判断访问站点设备(手机还是PC)实现自动跳转代码
- 网页访问,js判断是电脑访问还是手机访问
- 判断用户是pc访问还是手机访问
- php如何判断用户通过手机wap访问还是电脑直接访问
- 判断是手机还是电脑访问的代码
- js判断访问的当前设备是手机还是电脑
- jsp加载访问时判断是由手机web端还是pc端
- 利用PHP判断是手机移动端还是PC端访问的函数示例
- php判断手机访问还是电脑访问示例分享
- asp下通过HTTP_USER_AGENT判断用户是从手机上访问,还是电脑IE上访问
- 判断是手机还是电脑访问的代码
- php判断网页是手机访问还是pc端访问?
- js判断是手机访问还是电脑访问
- js判断当前的访问是手机还是电脑
- 【ASP.NET 进阶】判断访问网站的客户端是PC还是手机
- php判断是手机访问还是电脑访问
- js判断是手机访问还是电脑访问
- php判断终端是手机还是电脑访问网站代码
- 服务器判断是手机访问网址还是电脑访问网址