@PathVariable是用来获得请求url中的动态参数的
@RequestMapping("/kf/{date}")
public void example_1(@PathVariable(value = "date") String type) {}
@RequestParam注解主要有哪些参数:
value:参数名字,即入参的请求参数名字
required:是否必须,默认是true,表示请求中一定要有相应的参数
defaultValue:默认值,表示如果请求中没有同名参数时的默认值
@RequestMapping(value = "/service",method = RequestMethod.GET)
public void example_2(@RequestParam String type) {}
it’s very easy to be different,but very difficult to be better.
本文详细解析了Spring框架中@PathVariable与@RequestParam注解的使用方法,包括如何通过@PathVariable获取URL中的动态参数,以及@RequestParam注解的主要参数如value、required和defaultValue的作用。
326

被折叠的 条评论
为什么被折叠?



