위 챗 내 장 된 브 라 우 저 여 부 를 판단 합 니 다.

자바 버 전
import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class UaServlet extends HttpServlet {


    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        System.out.println("         :"+isMicroMessenger(request));

    }

    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

    }
    public static boolean isMicroMessenger(HttpServletRequest request1){
        boolean result=false;
        //      User-Agent
        String userAgent=request1.getHeader("User-Agent");
        System.out.println("      User-Agent:"+userAgent);
        //           
        if (userAgent.contains("MicroMessenger")){
            return true;
        }
        return result;
    }

}

javascript 버 전
    <script type="text/javascript"> function isMicroMessenger() { var result = false; var ua = window.navigator.userAgent; if(ua.indexOf('MicroMessenger') > -1) result = true; return result; } alert("       :"+ isMicroMessenger()); </script>

좋은 웹페이지 즐겨찾기