ブラウザバージョンとタイプを取得するための簡単なJavaメソッドは完璧ではありませんが、使用できます。
みんながそれを改善することを願っています!
public static void main(string [] args){string agent = request.getheader( "user-agent")。tolowercase(); system.out.println(agent); system.out.println( "+getbrowsername(agent));} public string getBrowsname(} return getBrows){return egid) "ie7";} else if(agent.indexof( "msie 8")> 0){return "ie8";} else if(agent.indexof( "msie 9")> 0){return "ie9";} "ie";} else if(agent.indexof( "opera")> 0){return "opera";} else if(agent.indexof( "opera")> 0){return "webkit";} "webkit";} else if(agent.indexof( "gecko")> 0 && agent.indexof( "rv:11")> 0){return "ie11";} else {return "others";}}}携帯電話かコンピューターブラウザかを判断する
public final static string [] agent = {"android"、 "iphone"、 "iPod"、 "iPad"、 "windows phone"、 "mqqbrowser"}; public static boolean checkagentismobile(string ua){boolean flag = fals; if(!ua.contains( "windows nt")||(ua.contains( ") ua.contains( "compatible; msie 9.0;"))))))))))))))))ua is:string ua = request.getheader( "user-agent"); //ブラウザによって返される応答ヘッダーの値が取得されます。
要約します
上記は、ブラウザのバージョンとタイプを決定するJava実装の簡単なコード例に関するこの記事のすべての内容です。私はそれが誰にでも役立つことを願っています。興味のある友人は、このサイトの他のJava関連のトピックを参照できます。欠点がある場合は、それを指摘するためにメッセージを残してください。このサイトへのご支援をありがとうございました!