【发布时间】:2023-03-18 03:06:01
【问题描述】:
我正在尝试使用 springMvc 和 thymeleaf 创建一个编辑表单。输入字段未填充从控制器返回的值。
控制器:
@RequestMapping(value = "updatecustomer")
public String search(@ModelAttribute("customerDto") CustomerDto customerDto, Model model) {
Customer customer = service.search(customerDto);
model.addAttribute("customer", customer);
return "mypage";
}
表格:
<form method="post" th:action="@{updatecustomer}" th:object="${customerDto}">
<label>Email: </label><input type="text" th:field="*{email}" />
<input type="submit" />
</form>
在浏览器上生成的 html:
<input type="text" id="email" name="email" value="">
调试显示值存在于控制器中并返回查看,但电子邮件输入值为空白。
请指教。
【问题讨论】:
标签: java html spring spring-mvc thymeleaf