@RequestParam注解的作用及用法

最简单的两种写法,在写接口时:加或不加@RequestParam注解的区别

第一种写法参数为非必传,第二种写法参数为必传。参数名为userId

第二种写法可以通过@RequestParam(required = false)设置为非必传。因为required值默认是true,所以默认必传

第二种写法可以通过@RequestParam("userId")或者@RequestParam(value = "userId")指定参数名

第二种写法可以通过@RequestParam(defaultValue = "0")指定参数默认值

用法如下:

posted @ 2018-08-12 21:14  龙芳伟  阅读(29838)  评论(0编辑  收藏  举报