javaweb中去除某个get方式的参数,并且返回路径
1 String requestURL = request.getRequestURL() + ""; 2 // String queryString = request.getQueryString(); 3 Enumeration<String> paraNames = request.getParameterNames(); 4 String queryparam = ""; 5 int tmp = 0; 6 for (Enumeration e = paraNames; e.hasMoreElements();) { 7 String thisName = e.nextElement().toString(); 8 if (StringUtils.isNotEmpty(thisName) 9 && !thisName.equals("code")) { 10 if (tmp == 0) { 11 queryparam = queryparam + thisName + "=" 12 + request.getParameter(thisName); 13 } else { 14 queryparam = queryparam + "&" + thisName + "=" 15 + request.getParameter(thisName); 16 } 17 tmp++; 18 } 19 } 20 requestURL = requestURI + "?" + queryparam;
获取参数参数值的方法是 request.getQuersyString();