Spring boot 如何在thymeleaf中设置输入标记的默认值?
你好, 设置字段的默认值时遇到问题。我使用的是Thymeleaf标记,但是字段和值标记不能一起工作。我正在寻找另一种解决方案,以便将默认值传递给字段 对于字段的第一个输入:th:field=“{technicalAttributes[${i.index}].name}”*我尝试设置默认值,但使用th:field标记时,th:value标记无效。 如何解决这个问题?提前感谢您抽出时间 我的输入代码示例:Spring boot 如何在thymeleaf中设置输入标记的默认值?,spring-boot,thymeleaf,Spring Boot,Thymeleaf,你好, 设置字段的默认值时遇到问题。我使用的是Thymeleaf标记,但是字段和值标记不能一起工作。我正在寻找另一种解决方案,以便将默认值传递给字段 对于字段的第一个输入:th:field=“{technicalAttributes[${i.index}].name}”*我尝试设置默认值,但使用th:field标记时,th:value标记无效。 如何解决这个问题?提前感谢您抽出时间 我的输入代码示例: <div class="form-group row" th:eac
<div class="form-group row" th:each="attribute, i: ${attributeList}">
<label class="col-sm-3 col-form-label" th:text="${attribute.name}"></label>
<div class="col-sm-9">
<input type="text" th:field="*{technicalAttributes[__${i.index}__].name}" th:value="${attribute.erpId}" class="form-control">
<input type="text" th:field="*{technicalAttributes[__${i.index}__].value}" class="form-control">
</div>
</div>
您需要在表单标记中传递对象technicalAttributes。您应该有如下内容:
<form th:action="@{/form}" th:object="${technicalAttributes}" method="post">
model.addAttribute("attributeList", attributeList);