JSTL 的 core标签库(JAVA EL 表达式)

来源:互联网 发布:php specialchar 编辑:程序博客网 时间:2024/05/24 06:22
JSTL core标签库

1. <c:out>

   <c:out value="${param.action}"></c:out>

2. <c:if>

   <c:if test="${param.action=='contion'}">
   </c:if>
   
if you need the process is similar to if ... else,  it should be use <c:choose> tag.

3. <c:choose>、 <c:when>、 <c:otherwise>

   <c:choose>
     <c:when test="${condition}">
       // TODO
     </c:when>
     <c:otherwise>
       // TODO
     </c:otherwise>
   </c:choose>
   

4. <c:forEach>

   a) normal round:
      for(int num=2;num<=100;num=num+2){}
      <c:forEach var="num" begin="2" end="100" step="2">
        // TODO
      </c:forEach>   
   
   b) traversal List:
      for(Object person:personList){
        person.getId();
        person.getName();
        person.getAge();
        ...
      }
      <c:forEach items="${personList}" var="person">
        <tr>
           <td>${person.id}</td>
           <td>${person.name}</td>
           <td>${person.age}</td>
           ...
         </tr>
      </c:forEach>
   
   c) traversal Map:
      <c:forEach var="item" items="${Map}">
        <tr>
          <td>${item.key}</td>
          <td>${item.value}</td>
        </tr>
      </c:forEach>
      
   d) Attribute: varStatus
   

5. <c:forTokend>

   <c:forTokend items="AA,BB,CC,DD,EE,FF,GG" delime"," var="item"
     varStatus="varStatus" begin="1" end="7" step="2">
     <tr>
       <td>${varStatus.index}</td>
       <td>${item}</td>
     </tr>   
   </c:forTokend>   
   
   Result:
   1    AA
   3    CC
   5    EE
   7    GG
   

6. <c:set>   


7. <c:remove>


8. <c:catch>


9. <c:import>


10. <c:url>


11. <c:redirect>


12. <c:param>

0 0