public static void main(String[] args) { String url = "http://localhost/DTKCPTSWJ/NewsDetail.aspx?PID=9&ClassID=19&NewsID=115"; String[] parameters = { "ClassID", "NewsID" }; String u; try { u = URLDecoder.decode(url, "UTF-8"); for (String s : parameters) { String[] a = new String[2]; if (u.indexOf(s) != -1) { a = (u.substring(u.indexOf(s))).split("&"); a[0].split("="); } System.out.println(a[0]); } } catch (UnsupportedEncodingException e) { e.printStackTrace(); } }
时间: 2024-10-13 01:16:07