當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpServletRequest.getParameterNames方法代碼示例

本文整理匯總了Java中javax.servlet.http.HttpServletRequest.getParameterNames方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpServletRequest.getParameterNames方法的具體用法?Java HttpServletRequest.getParameterNames怎麽用?Java HttpServletRequest.getParameterNames使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.servlet.http.HttpServletRequest的用法示例。


在下文中一共展示了HttpServletRequest.getParameterNames方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doPost

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    req.setCharacterEncoding("UTF-8");

    if (req.getRequestURI().endsWith("parseParametersBeforeParseParts")) {
        req.getParameterNames();
    }

    req.getPart("part");

    resp.setContentType("text/plain");
    resp.setCharacterEncoding("UTF-8");

    resp.getWriter().println("Part " + req.getParameter("part"));
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:17,代碼來源:TestRequest.java

示例2: createGetMethod

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private HttpMethod createGetMethod(HttpServletRequest req, String uri) throws ServletException,
        NotLoggedInException {

    GetMethod get = new GetMethod(uri);
    addUserNameToHeader(get, req);
    addAcceptEncodingHeader(get, req);

    get.getParams().setContentCharset("UTF-8");
    HttpMethodParams params = new HttpMethodParams();
    Enumeration e = req.getParameterNames();
    while (e.hasMoreElements()) {
        String paramName = (String) e.nextElement();
        for (String value : req.getParameterValues(paramName)) {
            params.setParameter(paramName, value);
        }
    }
    get.setParams(params);
    return get;
}
 
開發者ID:openNaEF,項目名稱:openNaEF,代碼行數:21,代碼來源:ForwarderServlet.java

示例3: processRequest

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
/**
 * Processes requests for both HTTP
 * <code>GET</code> and
 * <code>POST</code> methods.
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    try {
        if(sc==null)
       {
           sc = getServletConfig();
            if(sc!=null) init(sc);
       }
    

        Map<String, String> __params = new HashMap<String, String>();
        Enumeration __e = request.getParameterNames();
        while (__e.hasMoreElements()) {
            String tField = __e.nextElement().toString();
            __params.put(tField, request.getParameter(tField));
        }
        __params.put("contextpath", request.getContextPath());
        String __result=getResponce(__params);
        out.println(__result);
    } finally {  
        out.flush();
        out.close();
    }
}
 
開發者ID:dimasalomatine,項目名稱:sdirobot,代碼行數:37,代碼來源:Enter.java

示例4: doPost

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
/**
 * Only interested in the parameters and values for POST requests.
 */
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    // Just echo the parameters and values back as plain text
    resp.setContentType("text/plain");

    PrintWriter out = resp.getWriter();

    // Assume one value per attribute
    Enumeration<String> names = req.getParameterNames();
    while (names.hasMoreElements()) {
        String name = names.nextElement();
        out.println(name + "=" + req.getParameter(name));
    }
}
 
開發者ID:sunmingshuai,項目名稱:apache-tomcat-7.0.73-with-comment,代碼行數:19,代碼來源:TestRequest.java

示例5: createPostMethod

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
private HttpMethod createPostMethod(HttpServletRequest req, String redirectUrl) throws ServletException,
        NotLoggedInException {
    PostMethod post = new PostMethod(redirectUrl);
    addUserNameToHeader(post, req);
    addAcceptEncodingHeader(post, req);

    post.getParams().setContentCharset("UTF-8");
    List<NameValuePair> pairs = new ArrayList<NameValuePair>();
    @SuppressWarnings("unchecked")
    Enumeration e = req.getParameterNames();
    while (e.hasMoreElements()) {
        String paramName = (String) e.nextElement();
        String[] values = req.getParameterValues(paramName);
        for (String value : values) {
            NameValuePair pair = new NameValuePair(paramName, value);
            pairs.add(pair);
        }
    }
    post.addParameters(pairs.toArray(new NameValuePair[0]));
    return post;
}
 
開發者ID:openNaEF,項目名稱:openNaEF,代碼行數:22,代碼來源:ForwarderServlet.java

示例6: doBefore

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@Before("webLog()")
public void doBefore(JoinPoint joinPoint){
    log.info("------------日誌開始:"+LocalDateTime.now()+"------------");
    startTime.set(System.currentTimeMillis());
    // 接收到請求,記錄請求內容
    log.info("WebLogAspect.doBefore()");
    ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
    HttpServletRequest request = attributes.getRequest();
    // 記錄下請求內容
    log.info("URL : " + request.getRequestURL().toString());
    log.info("HTTP_METHOD : " + request.getMethod());
    log.info("IP : " + request.getRemoteAddr());
    log.info("CLASS_METHOD : " + joinPoint.getSignature().getDeclaringTypeName() + "." + joinPoint.getSignature().getName());
    log.info("ARGS : " + Arrays.toString(joinPoint.getArgs()));
    //獲取所有參數方法一:
    Enumeration enu=request.getParameterNames();
    while(enu.hasMoreElements()){
        String paraName=(String)enu.nextElement();
        log.info("PARAM :"+"("+paraName+" : "+request.getParameter(paraName)+")");
    }
}
 
開發者ID:TheWinding,項目名稱:Burst,代碼行數:22,代碼來源:WebLogAspect.java

示例7: removeParam

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
/**
 * 移除request指定參數
 * @param request
 * @param paramName
 * @return
 */
public String removeParam(HttpServletRequest request, String paramName) {
	String queryString = "";
	Enumeration keys = request.getParameterNames();
	while (keys.hasMoreElements()) {
		String key = (String) keys.nextElement();
		if (key.equals(paramName)) {
			continue;
		}
		if (queryString.equals("")) {
			queryString = key + "=" + request.getParameter(key);
		} else {
			queryString += "&" + key + "=" + request.getParameter(key);
		}
	}
	return queryString;
}
 
開發者ID:lgpzjp,項目名稱:rure,代碼行數:23,代碼來源:RequestUtil.java

示例8: getParameter

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
protected String getParameter(HttpServletRequest req, String parameter)
    throws ServletException {
  String value = req.getParameter(parameter);
  if (value == null || value.trim().isEmpty()) {
    if (DEBUG) {
      StringBuilder parameters = new StringBuilder();
      @SuppressWarnings("unchecked")
      Enumeration<String> names = req.getParameterNames();
      while (names.hasMoreElements()) {
        String name = names.nextElement();
        String param = req.getParameter(name);
        parameters.append(name).append("=").append(param).append("\n");
      }
      logger.fine("parameters: " + parameters);
    }
    throw new ServletException("Parameter " + parameter + " not found");
  }
  return value.trim();
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:20,代碼來源:BaseServlet.java

示例9: CGIProcessEnvironment

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
/**
 * Creates a ProcessEnvironment and derives the necessary environment,
 * working directory, command, etc.
 * @param req             HttpServletRequest for information provided by
 *                        the Servlet API
 * @param context         ServletContext for information provided by
 *                        the Servlet API
 * @param cgiPathPrefix   subdirectory of webAppRootDir below which the
 *                        web app's CGIs may be stored; can be null or "".
 * @param  debug          int debug level (0 == none, 6 == lots)
 */
public CGIProcessEnvironment(HttpServletRequest req,
    ServletContext context, String cgiPathPrefix, int debug) {
        super(req, context, debug);
        this.cgiPathPrefix = cgiPathPrefix;
        queryParameters = new Hashtable();
        Enumeration paramNames = req.getParameterNames();
        while (paramNames != null && paramNames.hasMoreElements()) {
            String param = paramNames.nextElement().toString();
            if (param != null) {
                queryParameters.put(param,
                    URLEncoder.encode(req.getParameter(param)));
            }
        }
        this.valid = deriveProcessEnvironment(req);
}
 
開發者ID:c-rainstorm,項目名稱:jerrydog,代碼行數:27,代碼來源:CGIProcessEnvironment.java

示例10: getSearchFilter

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
/**
 * 將請求參數封裝到SearchFilter
 * @param request javax.servlet.http.HttpServletRequest
 * @see SearchFilter
 * @return SearchFilter
 */
static SearchFilter getSearchFilter(HttpServletRequest request) {
    SearchFilter searchFilter = new SearchFilter();
    Enumeration<String> names = request.getParameterNames();
    while (names.hasMoreElements()) {
        String name = names.nextElement();
        if ("page".equals(name)) {
            searchFilter.setPage(Integer.parseInt(request.getParameter(name)));
            continue;
        }
        if ("rows".equals(name)) {
            searchFilter.setRows(Integer.parseInt(request.getParameter(name)));
            continue;
        }
        searchFilter.addParam(name, request.getParameter(name));
    }
    return searchFilter;
}
 
開發者ID:laohans,項目名稱:swallow-core,代碼行數:24,代碼來源:RequestHelper.java

示例11: buildParameters

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
protected Map<String, Object> buildParameters(HttpServletRequest req) {
	Map<String,Object> parameters=new HashMap<String,Object>();
	Enumeration<?> enumeration=req.getParameterNames();
	while(enumeration.hasMoreElements()){
		Object obj=enumeration.nextElement();
		if(obj==null){
			continue;
		}
		String name=obj.toString();
		String value=req.getParameter(name);
		if(name==null || value==null || name.startsWith("_")){
			continue;
		}
		parameters.put(name, decode(value));
	}
	return parameters;
}
 
開發者ID:youseries,項目名稱:ureport,代碼行數:18,代碼來源:BaseServletAction.java

示例12: catchAll

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@RequestMapping("/**")
public String catchAll(HttpServletRequest req, HttpServletResponse res) {
    log(req);

    StringBuffer postData = new StringBuffer();
    Enumeration<String> postParms = req.getParameterNames();
    while (postParms.hasMoreElements()) {
        String parm = postParms.nextElement();
        if ("access_token".equals(parm.toLowerCase())) {
            postData.append(parm).append("=").append("<redacted>");
        } else {
            if (postData.length() > 0) {
                postData.append("&");
            }
            postData.append(parm).append("=").append(req.getParameter(parm));
        }
    }

    log.debug("Unsupported URL: {} {}", req.getMethod(), req.getRequestURL());
    if (postData.length() > 0) {
        log.debug("POST data: {}", postData);
    }
    try {
        log.debug("Body: {}", IOUtils.toString(req.getInputStream(), StandardCharsets.UTF_8));
    } catch (IOException e) {
        log.debug("Body: Unable to read", e);
    }

    res.setStatus(HttpServletResponse.SC_NOT_FOUND);
    return DefaultExceptionHandler.handle("M_NOT_IMPLEMENTED", "Not implemented");
}
 
開發者ID:kamax-io,項目名稱:mxhsd,代碼行數:32,代碼來源:DefaultClientController.java

示例13: doFilter

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@Override
public void doFilter(ServletRequest request, ServletResponse response,
		FilterChain chain) throws IOException, ServletException {
	HttpServletRequest req = (HttpServletRequest) request;    
       HttpServletResponse res = (HttpServletResponse) response;    
       //獲得所有請求參數名    
       @SuppressWarnings("rawtypes")  
       Enumeration params = req.getParameterNames();    
   
       String sql = "";    
       while (params.hasMoreElements()) {    
           //得到參數名    
           String name = params.nextElement().toString();    
           //System.out.println("name===========================" + name + "--");    
           //得到參數對應值    
           String[] value = req.getParameterValues(name);    
           for (int i = 0; i < value.length; i++) {    
               sql = sql + value[i];    
           }    
       }    
       //System.out.println("============================SQL"+sql);    
       //有sql關鍵字,跳轉到error.html    
       if (sqlValidate(sql)) {    
           res.sendRedirect("error.html");    
           //String ip = req.getRemoteAddr();    
       } else {    
           chain.doFilter(req, res);    
       }    
}
 
開發者ID:xiachuanshou,項目名稱:shop-manager,代碼行數:30,代碼來源:SqlFilter.java

示例14: uploadImageData

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
public static List<String> uploadImageData(HttpServletRequest request) {
    List<String> fileNames = InstanceUtil.newArrayList();
    Enumeration<String> params = request.getParameterNames();
    String pathDir = getUploadDir(request);
    File dir = new File(pathDir);
    if (!dir.exists()) {
        dir.mkdirs();
    }
    while (params.hasMoreElements()) {
        String key = params.nextElement();
        String fileStr = request.getParameter(key);
        if (fileStr != null && !"".equals(fileStr)) {
            int index = fileStr.indexOf("base64");
            if (index > 0) {
                try {
                    String fileName = UUID.randomUUID().toString();
                    String preStr = fileStr.substring(0, index + 7);
                    String prefix = preStr.substring(preStr.indexOf("/") + 1, preStr.indexOf(";")).toLowerCase();
                    fileStr = fileStr.substring(fileStr.indexOf(",") + 1);
                    byte[] bb = Base64.getDecoder().decode(fileStr);
                    for (int j = 0; j < bb.length; ++j) {
                        if (bb[j] < 0) {// 調整異常數據
                            bb[j] += 256;
                        }
                    }
                    String distPath = pathDir + fileName + "." + prefix;
                    OutputStream out = new FileOutputStream(distPath);
                    out.write(bb);
                    out.flush();
                    out.close();
                    fileNames.add(fileName + "." + prefix);
                } catch (Exception e) {
                    logger.error("上傳文件異常:", e);
                }
            }
        }
    }
    return fileNames;
}
 
開發者ID:iBase4J,項目名稱:iBase4J-Common,代碼行數:40,代碼來源:UploadUtil.java

示例15: buildQueryParamsMap

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
protected static Map<String, Object> buildQueryParamsMap(HttpServletRequest request) {

        Map<String, Object> params = new HashMap<String, Object>();
        Enumeration<String> e = request.getParameterNames();

        StringBuilder tmpbuff = new StringBuilder();
        if (e.hasMoreElements()) {
            while (e.hasMoreElements()) {
                String name = e.nextElement();
                String[] values = request.getParameterValues(name);
                if (values.length == 1) {
                    if (StringUtils.isNotBlank(values[0]))
                        params.put(name, values[0]);
                } else {
                    tmpbuff.setLength(0);
                    for (int i = 0; i < values.length; i++) {
                        if (StringUtils.isNotBlank(values[i])) {
                            tmpbuff.append(values[i].trim()).append(",");
                        }
                    }
                    if (tmpbuff.length() > 0) {
                        tmpbuff.deleteCharAt(tmpbuff.length() - 1);
                        params.put(name, tmpbuff.toString());
                    }
                }
            }
        }
        return params;
    }
 
開發者ID:warlock-china,項目名稱:azeroth,代碼行數:30,代碼來源:RequestUtils.java


注:本文中的javax.servlet.http.HttpServletRequest.getParameterNames方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。