如何在jstl中使用break INENENCED for循环?

如何在jstl中使用break INENENCED for循环?,jstl,Jstl,如何在JSTL中使用中断增强for循环。 请检查我的密码 MyModelObject @RequestMapping(value="/g/{domainId}/{userId}/{userName}/fullProfile.htm" ,method=RequestMethod.GET) public String showFullProfile(@PathVariable("domainId")Long domainId,@PathVariable("userName")String userN

如何在JSTL中使用中断增强for循环。 请检查我的密码 MyModelObject

@RequestMapping(value="/g/{domainId}/{userId}/{userName}/fullProfile.htm" ,method=RequestMethod.GET)
public String showFullProfile(@PathVariable("domainId")Long domainId,@PathVariable("userName")String userName,@PathVariable("userId")Long userId,Model model) throws Exception {
     try {
                   List<Domains> domains = bal.getDomains();
                      model.put("domain",domains);
                }
                catch(Exception e)
              {
           }
return test;
}
@RequestMapping(value=“/g/{domainId}/{userId}/{userName}/fullProfile.htm”,method=RequestMethod.GET)
公共字符串showFullProfile(@PathVariable(“domainId”)Long domainId,@PathVariable(“userName”)字符串userName,@PathVariable(“userId”)Long userId,Model Model)引发异常{
试一试{
List domains=bal.getDomains();
模型.put(“域”,域);
}
捕获(例外e)
{
}
回归试验;
}
test.jsp

              <c:forEach items="${domain}" var="domain">
                 ${domain.departmentName}

                </c:forEach>

${domain.departmentName}

我的问题是每次我只获取6条记录,但当我的for循环达到第6条记录时,我想停止我的for循环。我如何才能做到这一点。请试一试,因为我没有测试

<c:set var="count" value="0" scope="page" />
<c:forEach items="${domain}" var="domain">
  <c:if test="${count < 6}">
    ${domain.departmentName}
    <c:set var="count" value="${count + 1}" scope="page" />
  </c:if>
</c:forEach>

${domain.departmentName}

使用forEach的varStatus属性

<c:forEach items="${domain}" var="domain" varStatus="status">
   <c:if test="${status.count le 6}">
      ${domain.departmentName}
   </c:if>
</c:forEach>

${domain.departmentName}