Java/JSTL/HTML Output — различия между версиями
Admin (обсуждение | вклад)  м (1 версия)  | 
				|
(нет различий) 
 | |
Текущая версия на 06:17, 1 июня 2010
Содержание
Out Default Examples
<%@ taglib uri="http://java.sun.ru/jstl/core" prefix="c" %>
<html>
  <head>
    <title>Out Default Examples</title>
  </head>
  <body>testit = 
  <c:out value="${testit}" default="Default Value" />
  </body>
</html>
   
   
Output a table
<%@ taglib uri="http://java.sun.ru/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.ru/jstl/core-rt" prefix="c-rt" %>
<html>
  <head>
    <title>Count to 10 Example(tracking even and odd)</title>
  </head>
  <body>
    <table border="0">
      <c:forEach var="i" begin="1" end="10" varStatus="status">
        <jsp:useBean id="status"
        type="javax.servlet.jsp.jstl.core.LoopTagStatus" />
        <c-rt:choose>
          <c-rt:when test="<%=status.getCount()%2==0%>">
            <c:set var="color" value="#eeeeee" />
          </c-rt:when>
          <c-rt:otherwise>
            <c:set var="color" value="#dddddd" />
          </c-rt:otherwise>
        </c-rt:choose>
        <tr>
          <td width="200" bgcolor="<c:out value="${color}"/>"> 
          <c:out value="${i}" />
          </td>
        </tr>
      </c:forEach>
    </table>
  </body>
</html>
   
   
Out with Tag Escaping Examples
<%@ taglib uri="http://java.sun.ru/jstl/core" prefix="c" %>
<html>
  <head>
    <title>Out with Tag Escaping Examples</title>
  </head>
  <body>
    <c:set var="test" scope="page">
      <table border="0">
        <tr>
          <td bgcolor="red"> </td>
          <td bgcolor="green"> </td>
        </tr>
        <tr>
          <td bgcolor="blue"> </td>
          <td bgcolor="yellow"> </td>
        </tr>
      </table>
    </c:set>
    <h3>Out With Encode=true</h3>
    <c:out value="${test}" escapeXml="true" />
    <br />
    <h3>Out With Encode=false</h3>
    <c:out value="${test}" escapeXml="false" />
    <br />
  </body>
</html>
   
   
Simple calculation and output
<%@ taglib uri="http://java.sun.ru/jstl/core" prefix="c" %>
<html>
  <head>
    <title>Out Examples</title>
  </head>
  <body>
  <h3>Out Example</h3>
  10 * 3 = 
  <c:out value="${10*3}" />
  <br />
  </body>
</html>