首先创建一个springboot项目
后面一直 next就生成项目了,
接下来创建一个实体类
以下几种方式可以获取数据!
// path
@RequestMapping("hello/{name}")
public String hello(@PathVariable String name) {
return "hello " + name + " !!";
}
// query string get
@RequestMapping("hello2")
public String hello2(@RequestParam String name,
@RequestParam String no) {
return String.format("hello %s, %s !!!", name, no);
}
// form data post
@RequestMapping("hello3")
public String hello3(StudentModel student) {
return String.format("hello %s, %s !!!", student.getName(), student.getNo());
}
// json
@RequestMapping("hello4")
public String hello4(@RequestBody StudentModel student) {
return String.format("hello %s, %s !!!", student.getName(), student.getNo());
}