Java Tutorial/JSTL/Form Action — различия между версиями

Материал из Java эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Версия 17:44, 31 мая 2010

JSTL Form Parameters

<html>
  <head>
  </head>
  <body>
    <form method="POST" action="form2.jsp">
      <table border="1" cellpadding="0" cellspacing="0"
      style="border-collapse: collapse" bordercolor="#111111"
      width="42%" id="AutoNumber1">
        <tr>
          <td width="100%" colspan="2" bgcolor="#0000FF">
            <p align="center">
              <b>
                <font size="4" color="#FFFFFF">Please Login</font>
              </b>
            </p>
          </td>
        </tr>
        <tr>
          <td width="19%">User Name</td>
          <td width="81%">
            <input type="text" name="uid" size="20" />
          </td>
        </tr>
        <tr>
          <td width="19%">Password</td>
          <td width="81%">
            <input type="password" name="pwd" size="20" />
          </td>
        </tr>
        <tr>
          <td width="100%" colspan="2">
            <p align="center">
              <input type="submit" value="Submit" name="action" />
              <input type="reset" value="Reset" name="B2" />
            </p>
          </td>
        </tr>
      </table>
    </form>
    <p align="left">
      <i>Note: you may use any ID/Password, security is not
      checked.</i>
    </p>
  </body>
</html>





Link to Self With Parameter Passing

<%@ taglib prefix="c" uri="http://java.sun.ru/jstl/core" %>
<c:set var="totalCount" scope="session" value="100"/>
<c:set var="perPage" scope="session" value="20"/>
<c:forEach
    var="boundaryStart"
    begin="0"
    end="${totalCount - 1}"
    step="${perPage}">
    



==  Post to the Same Page ==






   
  <!-- start source code -->
   
    <source lang="java">
<%@ taglib uri="http://java.sun.ru/jstl/core" prefix="c" %>
<html>
  <head>
    <title>If with Body</title>
  </head>
  <body>
    <c:if test="${pageContext.request.method=="POST"}">
      <c:if test="${param.guess=="5"}">You guessed my number!
      <br />
      <br />
      <br />
      </c:if>
      <c:if test="${param.guess!="5"}">You did not guess my number!
      <br />
      <br />
      <br />
      </c:if>
    </c:if>
    <form method="post">Guess what number I am thinking of?
    <input type="text" name="guess" />
    <input type="submit" value="Try!" />
    <br />
    </form>
  </body>
</html>





Use Form Parameter as Request Parameters in JSTL

<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 />
    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>