我很努力地找到一種方法來在Spring中接收選定的組合框值。在春天從組合框中獲取價值
這是HTML形式:
<form method="post" multiple="true">
Authhor: <label th:text="*{ownerName}" /><br />
Title: <label th:text="*{name}" /><br />
Description: <label th:text="*{description}" /><br />
Price: €<label th:text="*{price}" /><br />
Product: <select th:field="${productss}" th:remove="all-but-first">
<option th:each="product : ${productss}"
th:value="${product.id}" th:text="${product.name + ' (+ €' + product.price + ')'}">Productname</option>
</select><br />
<img width="250" heigth="250" th:src="*{plainURL}"/><br />
<button align="right" class="btn" type="submit" name="add" ><span class="glyphicon glyphicon-check">Add to shopping cart</span></button><br />
</form>
按鈕被點擊後,此基法在控制器執行:
@RequestMapping(value = IMAGE_ID, method = RequestMethod.POST, params = {"add"})
public String add(@PathVariable("id") int id, HttpSession session, Model model) {
...
return "redirect:/cart";
}
如何從在組合框接收所選擇的值方法?這樣
你有沒有嘗試使用<形式:選擇路徑= 「產品」> –