众所周知 程序猿 都是CURD 上手的 本篇文章 讲述 在Spring 3.0+ 框架 我们常用的几种Get请求 请求工具 我们选择PostMan
- 请求无参数
@RestController
@RequestMapping("/test")
public class Apitest {
@GetMapping("test1")
public void test1(){
System.out.println("这是一个无参的请求");
}
}
1.postMan请求方式
1. 结果 显示
2.单个请求参数
@RestController
@RequestMapping("/luck")
public class Apitest {
@GetMapping("/test2")
public void test2(Integer id){
System.out.println("id:"+id);
}
}
postMan 请求方式
请求结果
3.多个请求参数
@GetMapping("/test3")
public void test2(Integer id,String name){
System.out.println("id: "+id +"name: "+name);
}
3.PostMan 请求方式
3.请求结果
4.请求头携带参数
@GetMapping("/test4/{id}")
public void test4(@PathVariable(name = "id") Integer id){
System.out.println("id: "+id);
}
4.PostMan 请求
4.请求结果