本文主要是介绍Springboot带参数的的两种访问形式,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
Springboot带参数的的两种访问形式
- http://localhost:9000/test/test1?id=1
@RestController
@RequestMapping("/test")
public class TestController {
@RequestMapping("/test1")
public void say(@RequestParam("id") Integer id) {
System.out.println("访问成功");
}
}
- http://localhost:9000/test/test2/1
@RestController
@RequestMapping("/test")
public class TestController {
@RequestMapping("/test2/{id}")
public void test2(@PathVariable("id") Integer id) {
System.out.println("访问成功");
}
}
这篇关于Springboot带参数的的两种访问形式的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!