我正在尝试附加一个<br>
在表单中的每个输入行之后,但 Thymeleaf 一直给我解析错误。
这是我遇到问题的代码片段:
<form th:if="${not #lists.isEmpty(brands)}">
<input th:each="brand : ${brands}" type="checkbox" th:value="${brand.name}" th:utext="${brand.name + <br>}" />
</form>
如果我添加<br>
标签在输入标签之外,它不会将其添加到每一行。
提前致谢
我认为你可能以错误的方式处理这件事。
th:utext会插入那个within the <input>
节点。但是,根据HTML5 规范,什么都没有发生<input>
标签(“内容模型:空。”)
我想你想要更多这样的东西:
<form th:if="${not #lists.isEmpty(brands)}">
<th:block th:each="brand : ${brands}">
<label th:for="${#ids.next('brand')}" th:text="${brand.name}">Brand A</label>
<input type="checkbox" th:id="${#ids.seq('brand')}"
name="brand" th:value="${brand.name}"/>
<br/>
</th:block>
</form>
如果您使用 Spring MVC,您可能还会发现此示例很有帮助:http://www.thymeleaf.org/doc/tutorials/2.1/thymeleafspring.html#checkbox-fields
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)