jstl_core

<%@ page language="java" contentType="text/html; charset=GB18030"
 pageEncoding="GB18030"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=GB18030">
  <title>Insert title here</title>
 </head>
 <body>
  <h1> 
   测试JSTL核心库 
  </h1>
  <hr>
  <p>
  <li>
   采用c:out标签输出
  </li>
  <br>
  hello(使用标签):
  <c:out value="123" />
  <br>
  hello(使用标签):
  <c:out value="hello" />
  <br>
  hello(使用标签):
  <c:out value="${hello}" />
  <br>
  hello(使用EL标签)default:${hello1111}
  <br>
  hello(使用c:out)default:
  <c:out value="${hello111}" default="没有值"></c:out>
  <br>
  hello(使用c:out)default:
  <c:out value="${hello11}">没有值</c:out>
  <br>
  welcome(EL):${welcome }
  <br>
  welcome(标签):
  <c:out value="${welcome}" escapeXml="true"></c:out>
  <br>
  welcome(标签):
  <c:out value="${welcome}" escapeXml="false"></c:out>
  <br>
  <p>
  <li>测试c:ser,c:remove</li><br>
  <c:set value="root" var="userid"></c:set>
  userid:${userid }<br>
  <c:remove var="userid"/>
  userid:${userid }<br>
  <p>
  <li>条件控制标签:c:if</li><br>
  <c:if test="${v1 lt v2}">v1小于v2</c:if><br>
  <p>
  <li>条件控制标签:c:chose, c:when, c:otherwise</li><br>
  <c:choose>
   <c:when test="${v1 gt v2}">
    v1大于v2<br>
   </c:when>
   <c:otherwise>
    v1小于v2<br>
   </c:otherwise>
  </c:choose>
  
  <c:choose>
   <c:when test="${empty userList}">
    没有符合条件的数据
   </c:when>
   <c:otherwise>
    存在此数据
   </c:otherwise>
  </c:choose>
  <p>
  <li>演示循环控制标签:forEach</li><br>
  <table border="1">
   <tr>
    <td>姓名</td>
    <td>年龄</td>
    <td>组别</td>
   </tr>
   <c:choose>
    <c:when test="${empty users}">
     <tr>
      <td colspan="3">没有符合条件的数据</td>
     </tr>
    </c:when>
    <c:otherwise>
     <c:forEach items="${users}" var="user">
     <tr>
      <td>${user.userName }</td>
      <td>${user.age }</td>
      <td>${user.group.name }</td>
     </tr>     
     </c:forEach>
    </c:otherwise>
   </c:choose>
  </table>
  <p>
  <li>varStatus</li>
  <table border="1">
   <tr>
    <td>姓名</td>
    <td>年龄</td>
    <td>组别</td>
   </tr>
   <c:choose>
    <c:when test="${empty users}">
     <tr>
      <td colspan="3">没有符合条件的数据</td>
     </tr>
    </c:when>
    <c:otherwise>
     <c:forEach items="${users}" var="user" varStatus="vs">
      <c:choose>
       <c:when test="${vs.count mod 2 == 0}">
        <tr bgcolor=red>
       </c:when>
       <c:otherwise>
        <tr>
       </c:otherwise>
      </c:choose>
      <td>${user.userName }</td>
      <td>${user.age }</td>
      <td>${user.group.name }</td>
     </tr>
     </c:forEach>
    </c:otherwise>
   </c:choose>
  </table>
  
   <p>
  <li>演示循环控制标签:forEach</li><br>
  <table border="1">
   <tr>
    <td>姓名</td>
    <td>年龄</td>
    <td>组别</td>
   </tr>
   <c:choose>
    <c:when test="${empty users}">
     <tr>
      <td colspan="3">没有符合条件的数据</td>
     </tr>
    </c:when>
    <c:otherwise>
     <c:forEach items="${users}" var="user" begin="2" end="8" step="2">
     <tr>
      <td>${user.userName }</td>
      <td>${user.age }</td>
      <td>${user.group.name }</td>
     </tr>     
     </c:forEach>
    </c:otherwise>
   </c:choose>
  </table>
  <li>演示循环标签forEach,输出map</li><br>
  <c:forEach items="${map}" var="entry">
   ${entry.key }, ${entry.value } <br>
  </c:forEach>
  <p>
  <li>循环控制标签:forTokens</li><br>
  <c:forTokens items="${strTokens}" delims="#" var="v">
  ${v }<br>
  </c:forTokens>
  <p>
  <c:catch var="msg">
   <%
   Integer.parseInt("1dddd");
    %>
  </c:catch>
  ${msg }
  
  <p>
  <c:import url="http://www.baidu.com"></c:import>
  <p>
  <c:url value="http://www.baidu.com" var="v">
   <c:param name="userId" value="hugui"></c:param>
   <c:param name="age" value="20"></c:param>
  </c:url>
  ${v }<br>
  <li>c:redirect</li><br>
  <c:redirect url="/login.jsp"   context="/drp4.5" ></c:redirect>
 </body>
</html>

 

 

 



你可能感兴趣的:(html,C++,c,jsp,C#)