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}"/>