java獲得客服端信息的辦法(體系,閱讀器等)。本站提示廣大學習愛好者:(java獲得客服端信息的辦法(體系,閱讀器等))文章只能為提供參考,不一定能成為您想要的結果。以下是java獲得客服端信息的辦法(體系,閱讀器等)正文
以下所示:
String agent = request.getHeader("user-agent"); System.out.println(agent); StringTokenizer st = new StringTokenizer(agent,";"); st.nextToken(); String userbrowser = st.nextToken(); System.out.println(userbrowser); String useros = st.nextToken(); System.out.println(useros); System.out.println(System.getProperty("os.name")); //win2003居然是win xp? System.out.println(System.getProperty("os.version")); System.out.println(System.getProperty("os.arch")); System.out.println(request.getHeader("user-agent")); //前往客戶端閱讀器的版本號、類型 System.out.println(request.getMethod()); //:取得客戶端向辦事器端傳送數據的辦法有get、post、put等類型 System.out.println(request.getRequestURI()); //:取得收回要求字符串的客戶端地址 System.out.println(request.getServletPath()); //:取得客戶端所要求的劇本文件的文件途徑 System.out.println(request.getServerName()); //:取得辦事器的名字 System.out.println(request.getServerPort()); //:取得辦事器的端標語 System.out.println(request.getRemoteAddr()); //:取得客戶真個ip地址 System.out.println(request.getRemoteHost()); //:取得客戶端電腦的名字,若掉敗,則前往客戶端電腦的ip地址 System.out.println(request.getProtocol()); //: System.out.println(request.getHeaderNames()); //:前往一切request header的名字,成果集是一個enumeration(列舉)類的實例 System.out.println("Protocol: " + request.getProtocol()); System.out.println("Scheme: " + request.getScheme()); System.out.println("Server Name: " + request.getServerName() ); System.out.println("Server Port: " + request.getServerPort()); System.out.println("Protocol: " + request.getProtocol()); System.out.println("Server Info: " + getServletConfig().getServletContext().getServerInfo()); System.out.println("Remote Addr: " + request.getRemoteAddr()); System.out.println("Remote Host: " + request.getRemoteHost()); System.out.println("Character Encoding: " + request.getCharacterEncoding()); System.out.println("Content Length: " + request.getContentLength()); System.out.println("Content Type: "+ request.getContentType()); System.out.println("Auth Type: " + request.getAuthType()); System.out.println("HTTP Method: " + request.getMethod()); System.out.println("Path Info: " + request.getPathInfo()); System.out.println("Path Trans: " + request.getPathTranslated()); System.out.println("Query String: " + request.getQueryString()); System.out.println("Remote User: " + request.getRemoteUser()); System.out.println("Session Id: " + request.getRequestedSessionId()); System.out.println("Request URI: " + request.getRequestURI()); System.out.println("Servlet Path: " + request.getServletPath()); System.out.println("Accept: " + request.getHeader("Accept")); System.out.println("Host: " + request.getHeader("Host")); System.out.println("Referer : " + request.getHeader("Referer")); System.out.println("Accept-Language : " + request.getHeader("Accept-Language")); System.out.println("Accept-Encoding : " + request.getHeader("Accept-Encoding")); System.out.println("User-Agent : " + request.getHeader("User-Agent")); System.out.println("Connection : " + request.getHeader("Connection")); System.out.println("Cookie : " + request.getHeader("Cookie"));
取得user-agent的值
在 ASP.NET 中應用 Request.Header["User-Agent"] 獲得閱讀器的 User Agent,也能夠應用 Request.UserAgent 來獲得;
Java 中應用 request.getHeader(”User-Agent”) 來取得;
PHP 中響應應用:$_SERVER[HTTP_USER_AGENT];
JS中則應用navigator.userAgent來取得(客戶端常常應用它來做閱讀器兼容)。
以上就是小編為年夜家帶來的java獲得客服端信息的辦法(體系,閱讀器等)的全體內容了,願望對年夜家有所贊助,多多支撐~