1
1
package controller ;
2
2
3
+ import com .alibaba .fastjson .JSON ;
3
4
import domain .UserInfo ;
4
5
import org .springframework .stereotype .Controller ;
5
6
import org .springframework .web .bind .annotation .RequestMapping ;
7
+ import org .springframework .web .bind .annotation .ResponseBody ;
6
8
import org .springframework .web .servlet .ModelAndView ;
7
9
import service .UserService ;
8
10
9
11
import javax .annotation .Resource ;
12
+ import java .util .ArrayList ;
13
+ import java .util .List ;
10
14
11
15
/**
12
16
* Created by pengfei on 2017/9/3.
@@ -26,4 +30,68 @@ public ModelAndView helloWorld() {
26
30
return mv ;
27
31
}
28
32
33
+ @ RequestMapping (value = "/home/listUser" )
34
+ @ ResponseBody
35
+ public String getAllUser () {
36
+ List list = new ArrayList <TestObj >();
37
+ for (int i = 0 ; i < 105 ; i ++) {
38
+
39
+ int status =i %9 ;
40
+
41
+ TestObj temp = new TestObj (Integer .toString (i ), "name" + i , "price" + i ,Integer .toString (status ));
42
+
43
+ list .add (temp );
44
+ }
45
+
46
+ String resultJson = JSON .toJSONString (list );
47
+ return resultJson ;
48
+ }
49
+
50
+
29
51
}
52
+
53
+ class TestObj {
54
+ private String id ;
55
+ private String name ;
56
+ private String price ;
57
+ private String status ;
58
+
59
+ public TestObj (String id , String name , String price ,String status ) {
60
+ this .id = id ;
61
+ this .name = name ;
62
+ this .price = price ;
63
+ this .status =status ;
64
+ }
65
+
66
+ public String getId () {
67
+ return id ;
68
+ }
69
+
70
+ public void setId (String id ) {
71
+ this .id = id ;
72
+ }
73
+
74
+ public String getName () {
75
+ return name ;
76
+ }
77
+
78
+ public void setName (String name ) {
79
+ this .name = name ;
80
+ }
81
+
82
+ public String getPrice () {
83
+ return price ;
84
+ }
85
+
86
+ public void setPrice (String price ) {
87
+ this .price = price ;
88
+ }
89
+
90
+ public String getStatus () {
91
+ return status ;
92
+ }
93
+
94
+ public void setStatus (String status ) {
95
+ this .status = status ;
96
+ }
97
+ }
0 commit comments