1
我正在從事此spring-boot
項目,並且我正在從controller
方法返回ModelAndView
對象,我已將2個對象添加到ModelAndView
。這部分工作,我想知道如何表示thymeleaf
模板中的值。如何在thymeleaf模板內表示2個模型對象
public ModelAndView showEdit(@PathVariable int id,Customer cust,Model model){
ModelAndView view = new ModelAndView();
view.setViewName("editCustom");
view.addObject("cust",cust);
view.addObject("log",login);
}
裏面的thymeleaf
模板。
<form action="#" th:action="@{/save}" th:object="${cust}" method="post">
Name:<input type="text" th:field="*{name}" />
我可以獲取在cust
值,但我不知道如何從login
得到的值。 我試過這個,但它沒有working.note,所有的輸入標籤都在同一個表單中。
<input type="text" id="user" name="user" value="${login.uname}"/>