我正在使用 Thymeleaf 作為模板引擎撰寫一個帶有 CRUD 操作的簡單 Web 應用程式。問題是,這是我的代碼:
<form th:method="POST" th:action="@{/}">
<div>
<ul th:each="balloon: ${balloons}" style="list-style-type: none">
<li>
<input type="radio" name="balloonType" th:text="${balloon.getName()}"
th:value="${balloon.getDescription()}">
</li>
<div>
<form th:method="POST" th:action="@{'/balloons/delete/{id}' (id=${balloon.getId()})}">
<input type="submit" value="Delete">
</form>
</div>
</ul>
<input type="submit" value="Submit">
</div>
<br/>
</form>
當我運行應用程式時,inspect 元素中的代碼如下圖所示。第一個洗掉按鈕沒有以自己的形式出現,因此不能正常作業。歡迎任何幫助。

uj5u.com熱心網友回復:
你不能也不應該有嵌套的表單標簽。這是一個不好的做法。我會說你把它們分開如下:
<form action="/form1action1"...>
</form>
<form action="/form2action2"...>
</form>
如果您必須在表單中執行某些操作,請引入一些 JavaScript(或 ajax 或 jQuery,如果您愿意)片段。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/389331.html
上一篇:來自回呼的狀態更新
