表达式无法被解析的原因是什么?Controller
页面标签
显示内容
学习是最好的投资!
Spring的Controller方法裡面 Model是透過方法參數注入進去的類似於這樣:
@RequestMapping("welcome") public String welcome(Model model) { model.addAttribute("whatever", new SomeObject()); return "welcome"; }
如果使用ModelAndView 要這樣做
@RequestMapping("welcome") public ModelAndView welcome() { ModelAndView mv = new ModelAndView("welcome"); mv.addObject("whatever", new SomeObject()); return mv; }
另外View裡不是應該這樣寫嘛
<tr> <th th:text="#{whatever}">Name</th> <th th:text="#{whatever}">Price</th> </tr>
建議以後問問題 程式碼不要截圖 用文字 最好附帶完整原始碼放在git倉庫裡。
Spring的Controller方法裡面 Model是透過方法參數注入進去的
類似於這樣:
如果使用ModelAndView 要這樣做
另外View裡不是應該這樣寫嘛
建議以後問問題 程式碼不要截圖 用文字 最好附帶完整原始碼放在git倉庫裡。