Restful风格

Restful风格

//传统的RequestMapping请求的传参 
//http://localhost/8080/test?a=1&b=2
@RequestMapping("/test")
public void test(int a,int b){};

//Restful风格的RequestMapping请求传参
//http://localhost/8080/test/1/2
@RequestMapping("/test/{a}/{b}")
public void test(@PathVariable int a,@PathVariable int b){};
//通过添加@PathVariable注解使得可以直接参数值

posted @ 2020-09-02 16:47  知南而北游  阅读(141)  评论(0)    收藏  举报