Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.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 Thymeleaf对象绑定列表_Spring_Forms_Spring Mvc_Thymeleaf - Fatal编程技术网

Spring Thymeleaf对象绑定列表

Spring Thymeleaf对象绑定列表,spring,forms,spring-mvc,thymeleaf,Spring,Forms,Spring Mvc,Thymeleaf,这是我从数据库中检索到的对象: @RequestMapping("/category/edit/{id}") @org.springframework.transaction.annotation.Transactional public ModelAndView displayCategoryList(@PathVariable("id")Integer id){ ModelAndView mav = new ModelAndView("category-form"); Lis

这是我从数据库中检索到的对象:

@RequestMapping("/category/edit/{id}")
@org.springframework.transaction.annotation.Transactional
public ModelAndView displayCategoryList(@PathVariable("id")Integer id){
    ModelAndView mav = new ModelAndView("category-form");
    List<CatFeatGroup> catFeatGroupList = catFeatGroupService.findGroupsForCategory(id);
    mav.addObject("catFeatGroupList",catFeatGroupList);
    return  mav;
}
@RequestMapping(“/category/edit/{id}”)
@org.springframework.transaction.annotation.Transactional
公共ModelAndView displayCategoryList(@PathVariable(“id”)整数id){
ModelAndView mav=新的ModelAndView(“类别表”);
List catFeatGroupList=catFeatGroupService.findGroupsForCategory(id);
mav.addObject(“catFeatGroupList”,catFeatGroupList);
返回mav;
}
这是我的表格

<form class="form-horizontal">
    <div th:each="catFeatGroup,status : ${catFeatGroupList}" class="form-group">
        <label>Position</label><input th:field="catFeatGroupList[${status.index}].position"  th:value="${catFeatGroup.position}" />
        <label>Name</label> <input name="catGroupList[${status.index}].name" th:value="${catFeatGroup.name}" />
    </div>
    <button type="submit" class="btn btn-default">Submit</button>
</form>

位置
名称
提交
我需要使用
th:field
绑定该对象,但出现以下错误:

无法分析为表达式:“catFeatGroupList[${status.index}].position”

像这样添加“_u”符号

<form class="form-horizontal">
    <div th:each="catFeatGroup,status : ${catFeatGroupList}" class="form-group">
        <label>Position</label><input th:field="*{catFeatGroupList[__${status.index}__].position}"  th:value="${catFeatGroup.position}" />
        <label>Name</label> <input data-th-name="*{catFeatGroupList[__${status.index}__].name}" th:value="${catFeatGroup.name}" />
    </div>
    <button type="submit" class="btn btn-default">Submit</button>
</form>

位置
名称
提交

非常感谢。