이 문제에 접근하는 방법을 잘 모르겠습니다. 제품 정보가있는 데이터 테이블로 렌더링 된 테이블이 있습니다. 수량 및 할인 값을 삽입 할 수있는 양식을 알아 내려고 수량> 0 인 선택된 필드 또는 필드를 저장하십시오. 그런 다음 테이블 데이터를 세트 또는 목록에 바인드하십시오.스프링 부트에서 폼의 테이블을 HashSet에 바인딩하려면 어떻게해야합니까?
그러나 바인딩을 작성하는 방법을 잘 모르겠습니다. 나는이 question을 읽었지 만, 많은 양의 제품이있을 수 있으므로 잠재적으로 응답에서 많은 양의 null이있을 수 있으므로 인덱스를 사용할 수 있다고 생각하지 않는다는 점에서 상당히 똑같지는 않습니다. 어떤 도움을 주시면 감사하겠습니다.
Product.java
@Entity
@Table(name="products")
public class Product {
@Getter
@Setter
@Id
private Long productId;
@Getter
@Setter
private Long productName;
}
QuoteForm.java
public class QuoteForm {
@Getter
@Setter
private Long quoteId;
@Getter
@Setter
private Long contactId;
@Getter
@Setter
private Set<ProductEntry> products;
}
ProductEntry.java
public class ProductEntry {
@Getter
@Setter
private TempProduct product;
@Getter
@Setter
private Long quantity;
@Getter
@Setter
private float discount;
}
<form id="productTable" th:object="${quoteForm}">
<input type="number" th:field="*{contactId}"></input>
<table id ="productList"
class="table table-striped table-bordered"
cellspacing="0"
width="100%">
<thead>
<tr>
<th>Name</th>
<th>Quantity</th>
<th>Discount</th>
</tr>
</thead>
<tbody>
<tr th:each="product : ${productData.getProducts()}">
<td name="?">
<a th:text="${product.getProductName()}"
th:href="@{|/product/records/${product.getProductId()}|}">
</a>
</td>
<td>
<input type="number"
name="?"
th:field="*{products.quantity}">
</input>
</td>
<td>
<input type="number" name="?" th:field="*{products.discount}"></input>
</td>
</tr>
</tbody>
,691 form.html