thymeleaf 表单list提交 ?

新手上路,请多包涵

thymeleaf 表单中提交list

我想在Thymeleaf表单提交一个list对象
他的结构是这样的

    [{
    id:'',
    mouvalue:''    
}]

看了网上的教程是这样写的,如下:

   <div th:each="water,stat:${list}">
            <div class="form-group" th:style="${water.isUnusual==0?'':'color:red'}">
                <input type="hidden"  th:field="*{list[__${stat.index}__].id}"  th:value="${water.id}"/>
                <label class="control-label col-sm-4"><font style="padding-right: 4px">*</font><span
                        th:text="${water.detectionitemName}"></span></label>
                <div class="controls col-sm-4">
                    <input    th:field="*{list[__${stat.index}__].monvalue}" maxlength="50" th:value="${water.monvalue}"
                           class="form-control    "/>
                </div>
            </div>
        </div>

但是打开页面之后不显示each 循环的列
这样写就可以显示,但是提交到后台接口就会出现这个错误


        <div th:each="water,stat:${list}">
            <div class="form-group" th:style="${water.isUnusual==0?'':'color:red'}">
                <input type="hidden"   th:name="list[+${stat.index}+].id" th:value="${water.id}"/>
                <label class="control-label col-sm-4"><font style="padding-right: 4px">*</font><span
                        th:text="${water.detectionitemName}"></span></label>
                <div class="controls col-sm-4">
                    <input    th:name="list[+${stat.index}+].monvalue" maxlength="50" th:value="${water.monvalue}"
                           class="form-control    "/>
                </div>
            </div>
        </div>

image.png
求解

阅读 2.4k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题