zoukankan      html  css  js  c++  java
  • java遍历http请求request的所有参数实现方法

    方法一:

    通过程序遍历http请求的所有参数放到hashmap中,用的时候方便了。

    如果参数值有中文,那么需要在程序中添加filter转码,或者在下面程序里,对paramValue转码

    Map map = new HashMap(); 
       Enumeration paramNames = request.getParameterNames(); 
      while (paramNames.hasMoreElements()) { 
       String paramName = (String) paramNames.nextElement(); 
      
       String[] paramValues = request.getParameterValues(paramName); 
       if (paramValues.length == 1) { 
        String paramValue = paramValues[0]; 
        if (paramValue.length() != 0) { 
         System.out.println("参数:" + paramName + "=" + paramValue); 
         map.put(paramName, paramValue); 
        } 
       } 
      } 
    }
    

      方法二:

     Map paramMap = new HashMap();
     paramMap = request.getParameterMap();
    

      

  • 相关阅读:
    github的使用
    QPalette的用法
    QTimer的用法
    QStatusBar的用法
    QWhatsThis的用法
    QString::​arg的用法
    qt中ui的 使用介绍
    安全协议IPSEC
    安全协议ssl
    对称加密和非对称加密
  • 原文地址:https://www.cnblogs.com/shuiyelifang/p/9181542.html
Copyright © 2011-2022 走看看