ModelAttribute 和 RequestParam, PathVariable 之间的搭配

xiaoxiao2021-02-28  106

一: 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"); }

转载请注明原文地址: https://www.6miu.com/read-70253.html

最新回复(0)