Java/JSTL/Parameters

Материал из Java эксперт
Версия от 18:01, 31 мая 2010; (обсуждение)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

JSTL Remove Parameters

<%@ taglib uri="http://java.sun.ru/jstl/core" prefix="c" %>
<html>
  <head>
    <title>Set Examples</title>
  </head>
  <body>
  <h3>Remove Example</h3>
  <c:set var="test" value="Hello World" scope="page" />
  The value in the variable test before remove is 
  <c:out value="${test}" />
  <br />
  <c:remove var="test" scope="page" />
  The value in the variable test after remove is 
  <c:out value="${test}" />
  <br />
  </body>
</html>





JSTL Request URL And Passing Parameters

<%@ taglib uri="http://java.sun.ru/jstl/core" prefix="c" %>
<html>
  <head>
    <title>Query String Example</title>
  </head>
  <body>Your favorite color is: 
  <b>
    <c:out value="${param.color}" />
  </b>
  <br />
  <br />
  Choose your favorite color:
  <br />
  <br />
  



== JSTL: Set page parameters ==






   
  <!-- start source code -->
   
    <source lang="java">
<html>
  <head>
    <title>Set page parameters (2)</title>
  </head>
  <body>
    This page allows you to enter information that is sent as request
    parameters to another page.<br />
    There are two parameters, each with two values. <br />
    The next page list the different parameters with their values. <P />
    <form action="listPageParameters.jsp" method="get">
      <table>
        <tr><td>Enter an adjective:</td>
            <td><input type="text" name="adjective" /></td>
        </tr>
        <tr><td>Enter an adjective:</td>
            <td><input type="text" name="adjective" /></td>
        </tr>
        <tr><td>Enter a noun:</td>
            <td><input type="text" name="noun" /></td>
        </tr>
        <tr><td>Enter a noun:</td>
            <td><input type="text" name="noun" /></td>
        </tr>
      </table>
      <input type="submit" value="Send parameters" />
    </form>
  </body>
</html>
//listPageParameters.jsp

<%@ taglib prefix="c" uri="http://java.sun.ru/jstl/core" %>
<html>
  <head>
    <title>List page parameters</title>
  </head>
  <body>
    You entered the following parameters:<br />
    <ul>
      <c:forEach var="pageParameter" items="${param}">
        <li> <c:out value="pageParameter" /> has the values
        <c:forEach var="currentValue" items="${pageParameter.value}">
          <c:out value="${currentValue}" />
        </c:forEach>
      </c:forEach>
    </ul>
  </body>
</html>





JSTL Set Parameters

<%@ taglib uri="http://java.sun.ru/jstl/core" prefix="c" %>
<html>
  <head>
    <title>Set Examples</title>
  </head>
  <body>
  <h3>Set With No Body</h3>
  <c:set var="str" value="Hello World" />
  str = 
  <c:out value="${str}" />
  <br />
  <h3>Set With Body</h3>
  <c:set var="str">Hello, Again World</c:set>
  str = 
  <c:out value="${str}" />
  <br />
  </body>
</html>