0
私はJava、Thymeleafm、Bootstrap、Bootstrap-Selectを使用します。Thymeleaf - 多肢選択式
@RequestMapping(value = "/start", method = RequestMethod.GET)
//@ResponseBody //can be deleted due to thymeleaf
public String start() {
return "start";
}
@RequestMapping(value = "/start", method = RequestMethod.POST)
public String startPost(HttpServletRequest request, Model model) {
String productA = request.getParameter("Products");
System.out.println("product: " + productA);
return "start";
}
そして、それは私のHTMLです:: 私のレポはこちらhttps://github.com/realsony/thymeleaf
私のコントローラである
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org">
<head th:replace="template :: head">
</head>
<body>
<div th:replace="template :: body"></div>
<div class="container">
<form method="post" action="start.html">
<h2>Chose what you want to trade</h2>
<label>
<select th:name="Products" class="selectpicker" multiple="multiple">
<option th:value="Glas">Glas</option>
<option th:value="Table">Table</option>
<option th:value="Fork">Fork</option>
</select>
</label>
<button th:type="submit" class="btn btn-lg btn-info">Send</button>
</form>
</div>
</body>
</html>
私の問題
実際にユーザーが1を選択することができます-4製品はこちら。 1つの製品をクリックするとすぐに、コントローラに保存する必要があります。 しかし、それは動作していません。瞬間、参照「製品」は1つの選択肢のみを提供し、それ以上は提供しません。
誰かが私を助けてくれますか?
どのようにコントローラに選択肢を送信しているを削除するための/へ? – Janar
それは私の質問です:)私の考えは、製品オプションをクリックすることで、オプションがコントローラに保存されるということでした。オプションの選択を解除することにより、それを再度削除する必要があります。 – AnnaKlein