Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot 如何在thymeleaf中设置输入标记的默认值?_Spring Boot_Thymeleaf - Fatal编程技术网

Spring boot 如何在thymeleaf中设置输入标记的默认值?

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

你好,

设置字段的默认值时遇到问题。我使用的是Thymeleaf标记,但是字段和值标记不能一起工作。我正在寻找另一种解决方案,以便将默认值传递给字段

对于字段的第一个输入:th:field=“{technicalAttributes[${i.index}].name}”*我尝试设置默认值,但使用th:field标记时,th:value标记无效。 如何解决这个问题?提前感谢您抽出时间

我的输入代码示例:

<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);