-
Notifications
You must be signed in to change notification settings - Fork 12.3k
/
Copy pathExampleController.java
66 lines (55 loc) · 1.72 KB
/
ExampleController.java
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package com.neo.web;
import com.neo.model.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Controller
public class ExampleController {
@RequestMapping("/string")
public String string(ModelMap map) {
map.addAttribute("userName", "ityouknow");
return "string";
}
@RequestMapping("/if")
public String ifunless(ModelMap map) {
map.addAttribute("flag", "yes");
return "if";
}
@RequestMapping("/list")
public String list(ModelMap map) {
map.addAttribute("users", getUserList());
return "list";
}
@RequestMapping("/url")
public String url(ModelMap map) {
map.addAttribute("type", "link");
map.addAttribute("pageId", "springcloud/2017/09/11/");
map.addAttribute("img", "http://www.ityouknow.com/assets/images/neo.jpg");
return "url";
}
@RequestMapping("/eq")
public String eq(ModelMap map) {
map.addAttribute("name", "neo");
map.addAttribute("age", 30);
map.addAttribute("flag", "yes");
return "eq";
}
@RequestMapping("/switch")
public String switchcase(ModelMap map) {
map.addAttribute("gender", "woman");
return "switch";
}
private List<User> getUserList(){
List<User> list=new ArrayList<User>();
User user1=new User("大牛",12,"123456");
User user2=new User("小牛",6,"123563");
User user3=new User("纯洁的微笑",66,"666666");
list.add(user1);
list.add(user2);
list.add(user3);
return list;
}
}