【发布时间】:2017-09-20 06:07:16
【问题描述】:
尝试在百里香叶中创建表单,但我不断收到以下错误消息:
执行处理器“org.thymeleaf.spring4.processor.attr.SpringInputGeneralFieldAttrProcessor”时出错(customer-form:19)
这是我的 Thymeleaf 模板:
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<title>Save Customer</title>
<link type="text/css" rel="stylesheet" href="style.css"/>
<link type="text/css" rel="stylesheet" href="add-customer-style.css"/>
</head>
<body>
<div id="wrapper">
<div id="header">
<h2>Customer Relationship Manager</h2>
</div>
</div>
<div id="container">
<h3>Save Customer</h3>
<form action="saveCustomer" th:object="${customer}" method="post"/>
<table>
<tbody>
<tr>
<td><label>First Name</label></td>
<td><input type="text" th:field="*{firstName}"/></td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
以及持有它的控制器:
@Controller
public class CustomerController {
private ServiceDAO serviceDAO;
@Autowired
public void setServiceDAO(ServiceDAO serviceDAO) {
this.serviceDAO = serviceDAO;
}
@RequestMapping("/")
public String listCustomers(Model model){
List<Customer> customers = serviceDAO.findAll();
model.addAttribute("customers", customers);
return "home";
}
@GetMapping("/ShowFormForAdd")
public String ShowFormForAdd(Model model){
Customer customer = new Customer();
model.addAttribute("customer", customer);
return "customer-form";
}
}
【问题讨论】:
标签: spring-boot thymeleaf