Menos tonterías, ve directamente al código clave.
El código específico es el siguiente:
/*** Retire la ruta en la URL y deje la parte del parámetro de solicitud* @param Strurl URL Dirección* @return URL Parámetro de solicitud Parte* @author lzf*/private static string truncateUrlPage (String Strurl) {String StrallParam = null; String [] arrsplit = null; strurl = strurl.trim (). tolowerCase (); arrsplit = strurl.split ("[?]"); if (strurl.length ()> 1) {if (arrsplit.length> 1) {for (int i = 1; i <Rrsplit.length; i ++) {strallparam = arrsplit [i];}}} return strallParam; }/*** analice los pares de valor clave en los parámetros de URL* Por ejemplo, "index.jsp? Action = del & id = 123", analice la acción: del, id: 123 almacenado en el mapa* @param url URL Dirección* @return Solicitar Parámetro* @Author LZF*/Public estatic Map <String> URLS-URL (String Url URL Parámetro de parámetro* @Author LZF*/Public estatic mapRequest = new HashMap <String, String> (); String [] arrsplit = null; string strurlParam = truncateUrlPage (url); if (strurlparam == null) {return mapRequest;} arrsplit = strurlParam.split ("[&]"); para (string strsplit: arrsplit) arrsplitequal = null; arrsplitequal = strsplit.split ("[=]"); // analizar el valor clave if (arrsplitequal.length> 1) {// correctamente anal mapRequest.put (arrsplitequal [0], ""); }}} return MapRequest; }PD: Java intercepta el valor en la URL
MAP <String, Object> UrlSplit (String Data) {StringBuffer strBuf = new StringBuffer (); StringBuffer strBuf2 = new StringBuffer (); Map <String, Object> Map = New Hashmap <String, Object> (); para (INT I = 0; i <data.length (); i ++) {if (data.substring (i, i+1) .equals ("=")) {for (int n = i+1; n <data.length (); n ++) {if (data.substring (n, n+1) .equals ("&") == data.length ()-1) {map.put (strbuf.ToString (), strbuf2); strbuf = new StringBuffer (""); strbuf2 = nuevo StringBuffer (""); i = n; break;} strbuf2.append (data.substring (n, n+1));} continuar;} strbuf.append (data.substring (i, i+1));} retorno mapa;}Lo anterior es el método de interceptar parámetros de URL en Java y el método de interceptar valores de URL en Java. Espero que sea útil para todos. Si tiene alguna pregunta, déjame un mensaje y el editor responderá a todos a tiempo. ¡Muchas gracias por su apoyo al sitio web de Wulin.com!