public String editUserSumit(Model model, Integer id,@ModelAttribute("user") @Validated(value=(ValidationGroup1.class)) UserCustom userCustom, BindingResult bindingResult) throws Exception {}@ModelAttribute還可以將方法的返回值傳到頁面jsp頁面:<select name="allName"> <c:forEach items="${names }" var="item"> <option value="${item.key }">${item.value }</option> </c:forEach> </select>Controller:@ModelAttribute("names") public Map<String, String> userNames(){ Map<String, String> map = new HashMap<>(); map.put("1", "麥兜"); map.put("2", "奧特曼"); return map; }3.使用最簡單的方法 使用 model,可以不用@ModelAttributemodel.addAttribute("user", userCustom);4.簡單類型的數據回顯使用 model,不用@ModelAttributemodel.addAttribute("id", id);
新聞熱點
疑難解答