File tree Expand file tree Collapse file tree
src/main/java/info/cadecode/simple/controller Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,3 +4,8 @@ POST http://localhost:8080/api/demo/string
44Content-Type: application/json
55
66###
7+ # 测试 map 类型的返回
8+ POST http://localhost:8080/api/demo/m
9+ Content-Type: application/json
10+
11+ ###
Original file line number Diff line number Diff line change 11package info .cadecode .simple .controller ;
22
3+ import info .cadecode .simple .common .response .SimpleRes ;
34import org .springframework .web .bind .annotation .PostMapping ;
45import org .springframework .web .bind .annotation .RequestMapping ;
56import org .springframework .web .bind .annotation .RestController ;
67
8+ import java .util .HashMap ;
9+ import java .util .Map ;
10+
711/**
812 * @author Cade Li
913 * @date 2021/7/15
@@ -17,4 +21,13 @@ public class DemoController {
1721 public String string () {
1822 return "DemoController OK!" ;
1923 }
24+
25+ @ PostMapping ("map" )
26+ public Map <String , Object > map () {
27+ HashMap <String , Object > map = new HashMap <>();
28+ map .put ("name" , "map" );
29+ map .put ("msg" , "hello world" );
30+ return map ;
31+ }
32+
2033}
You can’t perform that action at this time.
0 commit comments