其他分享
首页 > 其他分享> > @RequestParam加与不加的区别

@RequestParam加与不加的区别

作者:互联网

 

最简单的两种写法,加或不加@RequestParam注解

@RequestMapping("/list")
public String test(int userId) {
  return "list";
}
@RequestMapping("/list")
public String test(@RequestParam int userId) {
  return "list"; }

区别: 

用法如下:

@RequestMapping("/list")
public String test(@RequestParam(value = "userId", defaultValue = "0", required = false) int userId) {
  return "list";
}

 

标签:不加,RequestParam,区别,int,userId,list,必传,写法
来源: https://www.cnblogs.com/yysbolg/p/10642432.html