forked from hellokaton/write-readable-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample3.java
More file actions
47 lines (37 loc) · 1.27 KB
/
Copy pathExample3.java
File metadata and controls
47 lines (37 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package chapter_05;
import java.util.Map;
/**
* 在需要时使用对齐
*
* @author biezhi
* @date 2018/7/3
*/
public class Example3 {
private Request request = new Request();
static class Request {
Request GET;
Request POST;
private Map<String, String> values;
public String get(String key) {
return values.get(key);
}
}
public void part1() {
// 从 POST 中获取数据
String company = request.POST.get("company");
String kindergarten = request.POST.get("kindergarten");
String subwayStation = request.POST.get("subwayStation");
String zoo = request.POST.get("zoo");
}
public void part2() {
// 从 POST 中获取数据
String company = request.POST.get("company");
String kindergarten = request.POST.get("kindergarten");
String subwayStation = request.POST.get("subwayStation");
String zoo = request.POST.get("zoo");
if (null != company) { /* company */}
if (null != subwayStation) { /* subwayStation // 这不是去幼儿园的车?*/}
if (null != zoo) { /* zoo */}
if (null != kindergarten) { /* kindergarten // 为什么我在幼儿园? */}
}
}