Java判断浏览器是微信还是支付宝
下面一段代码给大家介绍java判断浏览器是微信还是支付宝,具体代码如下所示:
@RequestMapping("getBrowser.do")
publicStringgetBrowser(HttpServletRequestreq,HttpServletResponseresp){
StringuserAgent=req.getHeader("user-agent");
if(userAgent!=null&&userAgent.contains("AlipayClient")){
return"来自支付宝";
}elseif(userAgent!=null&&userAgent.contains("MicroMessenger")){
return"来自微信";
}else{
return"未知来源";
}
}
补充:下面看下js识别微信支付宝浏览器(移动端)
//判断是支付宝app的浏览器
varuserAgent=navigator.userAgent.toLowerCase();
if(userAgent.match(/Alipay/i)=="alipay"){
returntrue;
}else{
returnfalse;
}
//判断是微信app的浏览器
functionisWechat(){
varuserAgent=navigator.userAgent.toLowerCase();
if(userAgent.match(/MicroMessenger/i)=="micromessenger"){
returntrue;
}else{
returnfalse;
}
}热门推荐
10 新人红包祝福语简短精辟
11 幼师给毕业祝福语简短
12 生日高考祝福语妹妹简短
13 下飞机祝福语简短英文
14 元宵发客户祝福语简短
15 爸妈金婚文案祝福语简短
16 新郎朋友红包祝福语简短
17 虎年五一祝福语大全简短
18 出阁宴祝福语姐姐简短