前段时间一直在做APP,springboot和vue的相关东西都有些忘记了,现在重新复习下,并记录,相信自己可以更好地成长起来
SpringBoot接收前台传递参数
通过get方式传参:
方式一:
//请求url: /web/test/100
@GetMapping(value = "/test/{uid}")
public Map getUser(@PathVariable String uid){
Map map = new HashMap<>();
map.put("uid",uid);
return testService.getUser(map);
}
方式二:
//请求Url /web/test?uid=100
@GetMapping(value = "/test")
public Map getUser(@RequestParam String uid){
styles.log("/web/test test请求");
Map map = new HashMap<>();
map.put("uid",uid);
return testService.getUser(map);
}
通过post请求传参:
方式一:
@PostMapping(value = "/test")
public Map getUser(@RequestParam String uid){
Map map = new HashMap<>();
map.put("uid",uid);
return testService.getUser(map);
}