通过请求头判断是什么浏览器
作者:互联网
public String mobile(HttpServletRequest request, HttpServletResponse response) { String userAgent = request.getHeader("User-Agent"); if(userAgent != null) { if(userAgent.toLowerCase().indexOf("iphone") > -1) { return "苹果手机"; } else if(userAgent.toLowerCase().indexOf("micromessenger") > -1) { return "微信"; } else if(userAgent.toLowerCase().indexOf("android") > -1) { return "android手机"; } } return ""; }
标签:判断,return,请求,indexOf,String,userAgent,浏览器,android,toLowerCase 来源: https://www.cnblogs.com/DreamFather/p/11326765.html