The following code introduces you to judging whether Java is a browser with WeChat or Alipay. The specific code is as follows:
@RequestMapping("getBrowser.do") public String getBrowser(HttpServletRequest req, HttpServletResponse resp) { String userAgent = req.getHeader("user-agent"); if (userAgent != null && userAgent.contains("AlipayClient")) { return "from Alipay"; }else if (userAgent != null && userAgent.contains("MicroMessenger")) { return "from WeChat"; }else{ return "Unknown Source"; } }Supplement: Let’s take a look at the js recognition WeChat Alipay browser (mobile terminal)
//Judge it is the browser of Alipay app var userAgent = navigator.userAgent.toLowerCase(); if(userAgent.match(/Alipay/i)=="alipay"){ return true; }else{ return false; } //Judge that it is a browser function of WeChat app isWechat(){ var userAgent = navigator.userAgent.toLowerCase(); if(userAgent.match(/MicroMessenger/i)=="micromessenger") { return true; } else { return false; }}