从表单传递未使用的字段

时间:2019-10-09 14:47:29

标签: spring spring-mvc thymeleaf

我想在发布表单后找回未使用的属性,如何绑定字段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<>();

的字段

0 个答案:

没有答案