Spring+Servlet+JSP頁面傳遞值的筆記
參考: https://www.ajoshow.com/2018/04/08/springjsp%E9%A0%81%E9%9D%A2%E5%82%B3%E9%81%9E%E5%80%BC%E7%9A%84%E7%AD%86%E8%A8%98/ 在Spring MVC中,三個主要傳遞值用的物件為Model、ModelMap、ModelAndView。 ModelAndView Model 為 interface 裡面的方法大致上有這些 Model addAttribute(String attributeName, Object attributeValue); Model addAttribute(Object attributeValue); Model addAllAttributes(Collection<?> attributeValues); ModelMap 為 class 算是Model的進化版 public ModelMap(String attributeName, Object attributeValue) { addAttribute(attributeName, attributeValue); } public ModelMap(Object attributeValue) { addAttribute(attributeValue); } public ModelMap addAttribute(String attributeName, Object attributeValue) { Assert.notNull(attributeName, "Model attribute name must not be null"); put(attributeName, attributeValue); return this; } public ModelMap addAttribute(Object attributeValue) { Assert.notNull(attributeValue, "Model object must not be null"); if (attributeValue instanceof Collection && ((C...