【发布时间】:2016-02-17 14:02:33
【问题描述】:
这是我的表格。
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="header :: head"></head>
<body>
<div th:replace="header :: head-nav"></div>
<div id="wrapper">
<div class="container-fluid">
<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="${catFeatGroupList[__${status.index}__].name}" th:value="${catFeatGroup.name}" />
</div>
<button type="submit" class="btn btn-default">Submit</button>
</div>
</div>
<div th:replace="footer :: foot"></div>
</body>
</html>
这是赋予它值的控制器
@RequestMapping("/category/edit/{id}")
@ModelAttribute("catFeatGroupList")
@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;
}
}
但是页面返回错误
java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'catFeatGroupList[0]' available as request attribute
我错过了什么
【问题讨论】:
标签: java forms spring-boot thymeleaf