当前位置: 首页>>代码示例>>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;未经允许,请勿转载。