您的位置:首页 > 产品设计 > UI/UE

ModelAttribute 和 RequestParam, PathVariable 之间的搭配

2017-05-07 10:51 393 查看
一: ModelAttribute RequestParam 搭配categoryId不会被添加到model

@RequestMapping(value = "/list", method = RequestMethod.GET)
public String list(@ModelAttribute("categoryId") @RequestParam("categoryId") Long categoryId, Model model) {
return viewName("list");
}


二:ModelAttribute PathVariable 搭配categoryId会被添加到model

@RequestMapping(value = "/list/{categoryId}", method = RequestMethod.GET)
public String list(@ModelAttribute("categoryId") @PathVariable("categoryId") Long categoryId, Model model) {
return viewName("list");
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐