The <c:forEach> tag has the following attributes:
Attributes | description | Is it necessary | Defaults |
---|---|---|---|
items | Information to be recycled | no | no |
begin | Starting element (0=first element, 1=second element) | no | 0 |
end | The last element (0=first element, 1=second element) | no | Last element |
step | The step size of each iteration | no | 1 |
where | The name of the variable representing the current entry | no | no |
varStatus | The name of the variable representing the loop state | no | no |
In general, items and var can be used, and varStatus is used when you want to get the current object index
Backstage
-
public ModelAndView toaddSmallBoard() {
-
/*需要获取板块信息*/
-
ModelAndView modelAndView=new ModelAndView();
-
List boards=boardService.getBoards();
-
modelAndView.addObject("boards",boards);
-
modelAndView.setViewName("admin/addSmallBoard");
-
return modelAndView;
-
}
Front desk
I used the select drop-down box here, and the specific use situation shows the situation
-
<select class="form-control" name="board.boFaterId">
-
<c:forEach items="${boards}" var="board" varStatus="id">
-
<option value="${board.boardId}">${board.boardName} </option>
-
</c:forEach>
-
</select>
effect