SpringMVC接收参数
参数通过json的方式,请求体
@PostMapping("/add")
public void add(@RequestBody Dept dept){
System.out.println(dept);
}
参数通过表单的方式,key=value
@PostMapping("/add")
public void add(Dept dept){
System.out.println(dept);
}
Rest风格
@GetMapping("/fun/{id}")
public void fun(@PathVariable Integer id){
System.out.println(id);
}
接收多个指定的参数
@GetMapping("/login")
public void login(@RequestParam("name") String name, @RequestParam("password") String password){
System.out.println(name+" "+ password);
}
还没有评论,来说两句吧...