首页 > 其他分享 >request获取请求数据的方法

request获取请求数据的方法

时间:2023-01-10 11:11:06浏览次数:41  
标签:username 请求 req request System 获取 String out

1.获取所有参数map集合

1 map<String,String [] >getParameterMap()

2.根据名称获取参数值(数组)

1 String[] fetParameterValues(String name)

3.根据名称获取参数值(单个值)

1 String getParameter(String name)

案例:

 1  //1. 获取所有参数的Map集合
 2         Map<String, String[]> map = req.getParameterMap();
 3         for (String key : map.keySet()) {
 4             // username:zhangsan lisi
 5             System.out.print(key+":");
 6 
 7             //获取值
 8             String[] values = map.get(key);
 9             for (String value : values) {
10                 System.out.print(value + " ");
11             }
12 
13             System.out.println();
14         }

 

1   String[] hobbies = req.getParameterValues("hobby");
2         for (String hobby : hobbies) {
3             System.out.println(hobby);
4         }
1  String username = req.getParameter("username");
2         String password = req.getParameter("password");
3         System.out.println(username);
4         System.out.println(password)

 

标签:username,请求,req,request,System,获取,String,out
From: https://www.cnblogs.com/daitu66/p/17039572.html

相关文章