2017-04-23 7 views
0

私Thymeleafフォームで間違っタイムの葉でフォームを作成しようとしていますが、私は以下のエラーメッセージ得続ける:プロセッサの実行中にいただきまし

エラー「org.thymeleaf.spring4.processor.attr.SpringInputGeneralFieldAttrProcessor」(顧客 - 体: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"; 
    } 

} 

答えて

2

入力欄の後にフォームタグを必ず閉じてください。次に、Thymeleafに適切に解決させるように行動を更新してください:

<form th: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> 
    </form> 
+0

ありがとうございます! –

+0

これがうまくいけば、チェックマークやアップヴォートでマークしてください。 – bphilipnyc

関連する問題