Java判断浏览器是微信还是支付宝
1 private static final String WX_AGENT = "micromessenger"; 2 private static final String ALI_AGENT = "alipay"; 3 4 5 public String getBrowser(HttpServletRequest request) { 6 String agent = request.getHeader("User-Agent").toLowerCase(); 7 if(agent!=null) { 8 if (agent.toLowerCase().contains(WX_AGENT)) { 9 return "来自微信"; 10 } else if (agent.toLowerCase().contains(ALI_AGENT)) { 11 return "来自支付宝"; 12 } 13 } 14 return "来自未知星球"; 15 }