2017-04-26 13 views
0

私は自分のアプリケーションをThymeleafに移植しています。リストのオブジェクトからフォームを作成する際に問題があります。フォームの選択とタイムリーフ

私はList<Plate> platesを持っていると私のReservationPlateフィールドを持っているので、それは(プレーンなJSPで働いていた)本当に基本的な選択の関連

だ私は」コントローラからこのフォーム

<form th:with="reservationUrl=(${price != null} ? '/book/confirm' : '/book/new')" 
th:action="@{${reservationUrl}}" method="POST" 
class="form-signin" th:object="${reservation}" 
id="form-signin"> 

    <div class="form-group row"> 
      <label class="col-sm-2 col-form-label" for="plate" 
      th:text="#{reservation.plate }">Targa</label> 
    <div class="col-sm-4 input-group"> 
    <select th:type="*{plate}" class="form-control"> 
      <option th:each="p : ${plates}" 
    th:value="${p.plateId}" th:text="${p.plateNumber}">Opzione</option> 
      </select> 
       </div> 
// rest of the form 

を持っていますmはこれがプレート

でこの例外に

Exception evaluating SpringEL expression: "p.plateId" (reservation:67)] with root cause 
Property or field 'plateId' cannot be found on object of type 'org.thymeleaf.util.EvaluationUtil$MapEntry' - maybe not public? 

を取得します

@Entity 
public class Plate { 

    @Id 
    @GeneratedValue(strategy = GenerationType.AUTO) 

    private Long plateId; 

    private String plateNumber; 

    private String plateName; 

    @ManyToOne 
    @JoinColumn(name="userId") 
    @JsonBackReference(value="plates-user-reference") 
    private User user; 

    private boolean favourite; 

    @JsonIgnore 
    private boolean enabled; 
    //standard getters and setters 
+0

'$ {plates} 'とは何ですか?投稿してくださいPlate item class – StanislavL

+0

Plate、thanks – besmart

+0

$ {plates}はリストであり地図ではありませんか? – Metroids

答えて

0

<div class="form-group"> 
        <label for="location">Pick a location:</label> 
        <select class="form-control" th:value="${appointment.location}" name="location" id="location" 
          > 
         <option disabled="disabled" selected="selected" > -- select the location --</option> 
         <option>Boston</option> 
         <option>New York</option> 
         <option>Chicago</option> 
         <option>San Francisco</option> 
        </select> 
       </div> 

ドロップダウンメニューを試してみたい場合は、その後の湯は、この方法に従うことができます。

関連する問題