我想在发布表单后找回未使用的属性,如何绑定字段orderIngredients?
@GetMapping("/new")
public String newIngredientForm(Model model){
Ingredient ingredient=new Ingredient();
OrderIngredient orderIngredient=new OrderIngredient();
orderIngredient.setQuantity(21);
ingredient.getOrderIngredients().add(orderIngredient);
model.addAttribute("ingredient",ingredient);
return "ingredients/ingredientForm";
}
我试图通过此字段orderIngredient来形成并隐藏它,但是没有用
<form th:object="${ingredient}" th:action="@{'/ingredients/new'}" method="post">
<fieldset>
<input type="hidden" th:field="*{orderIngredients}"/>
成分private Set<OrderIngredient> orderIngredients= new HashSet<>();