admin管理员组

文章数量:1613752

js端限制:

var agent = navigator.userAgent.toLowerCase();
var isWeixin = agent.indexOf('micromessenger') != -1;
if (!isWeixin) {
    window.location.href = "https://open.weixin.qq/connect/oauth2/authorize?appid=888"
}

java:pc端限制

/** 
  检查访问方式是否为移动端 
  @Title: check 
  @Date : 2019-9-7 下午04:15:33 
  @param request 
    @param response
  @throws IOException  
 */  
public boolean check(HttpServletRequest request,HttpServletResponse response) throws IOException{  
    boolean isFromMobile=false;  
      
    HttpSession session= request.getSession();  
   //检查是否已经记录访问方式(移动端或pc端)  
    if(null==session.getAttribute("agent")){  
        try{  
            //获取ua,用来判断是否为移动端访问  
            String userAgent = request.getHeader( "USER-AGENT" ).toLowerCase();    
            if(null == userAgent){    
                userAgent = "";    
            }  
            isFromMobile=CheckMobile.check(userAgent);  
            //判断是否为移动端访问  
            if(isFromMobile){  
                System.out.println("移动端访问");  
                session.setAttribute("agent","mobile");  
            } else {  
                System.out.println("pc端访问");  
                session.setAttribute("agent","pc");  
            }  
        }catch(Exception e){}  
    }else{  
        isFromMobile=session.getAttribute("agent").equals("mobile");  
    }  
      
    return isFromMobile;  
}

本文标签: 公众浏览器