The principle of implementation is to detect the user-agent of the browser and then determine the client type based on the regular form.
assumptions do not match, fallback fallback policy is to display the corresponding page. Let the user choose for themselves.
suitable for the use of two-dimensional code scanning mode to download the app:
the code for the JSP version number, such as the following see: Other server version number please Baidu search.
Original address: [You can also visit the Upward Exchange forum to see many other industries, open source, recruitment information]
<% @page import= "Java.util.regex.Matcher"%><% @page import= "java.util.regex.Pattern"%><%@ page Language= "java" pageencoding= "UTF-8"%><%!//\b is the word boundary (a logical interval between two (alphabetic and non-alphabetic characters), and the string is transcoded at compile time, so it is "\\b"//\b is the internal logical interval of the word (the logical interval between the two alphabetic characters that are attached) String Androidreg = "\\bandroid| nexus\\b "; String iosreg = "IP (hone|od|ad)"; Pattern Androidpat = Pattern.compile (Androidreg, pattern.case_insensitive); Pattern Iospat = Pattern.compile (Iosreg, pattern.case_insensitive);p ublic boolean likeandroid (String useragent) {if ( NULL = = useragent) {useragent = "";} Match Matcher matcherandroid = Androidpat.matcher (useragent), if (Matcherandroid.find ()) {return true;} else {return false ;}} public boolean Likeios (String useragent) {if (null = = useragent) {useragent = "";} Match Matcher Matcherios = Iospat.matcher (useragent), if (Matcherios.find ()) {return true;} else {return false;}} %><%string path = Request.getcontextpath (); String basepath = request.getscheme () + "://" +request.getservername () + ":" +request.getserVerport () +path+ "/";//string useragent = Request.getheader ("User-agent"). toLowerCase (); System.out.println ("useragent:" +useragent); if (null = = useragent) {useragent = "";} if (Likeandroid (useragent)) {System.out.println ("likeandroid:" +true); Response.sendredirect ("http://m.iyhjy.com/ Download.jsp?platform=android "); Return;//request.getrequestdispatcher ("/download.html "). Forward (Request, Response);} else if (Likeios (useragent)) {System.out.println ("Likeios:" +true); Response.sendredirect ("http://itunes.apple.com/ us/app/id714751061 "); Return;//request.getrequestdispatcher ("/index.html "). Forward (request,response);} %><! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
Infer the client phone type and jump to the corresponding app download page