【发布时间】:2016-09-12 00:19:06
【问题描述】:
我在这个spring-boot 项目中工作,我正在从我的controller 方法返回一个ModelAndView 对象,我已经向ModelAndView 添加了2 个对象。这部分正在工作,我想知道如何表示 thymeleaf 模板中的值。
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 中获取值。
我试过了,但它不起作用。注意所有输入标签都在同一个表单内。
<input type="text" id="user" name="user" value="${login.uname}"/>
【问题讨论】:
标签: spring jsp spring-mvc spring-boot thymeleaf