Java Tutorial/JSTL/Form Action
Содержание
JSTL Form Parameters
<source lang="java">
<html>
<head> </head> <body> <form method="POST" action="form2.jsp">
Please Login |
|
User Name |
<input type="text" name="uid" size="20" /> |
Password |
<input type="password" name="pwd" size="20" /> |
<input type="submit" value="Submit" name="action" /> <input type="reset" value="Reset" name="B2" /> |
</form>
Note: you may use any ID/Password, security is not checked.
</body>
</html></source>
Link to Self With Parameter Passing
<source lang="java">
<%@ 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
<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!
</c:if> <c:if test="${param.guess!="5"}">You did not guess my number!
</c:if> </c:if> <form method="post">Guess what number I am thinking of? <input type="text" name="guess" /> <input type="submit" value="Try!" />
</form> </body>
</html></source>
Use Form Parameter as Request Parameters in JSTL
<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.
The next page list the different parameters with their values. <P /> <form action="listPageParameters.jsp" method="get">
Enter an adjective: | <input type="text" name="adjective" /> |
Enter an adjective: | <input type="text" name="adjective" /> |
Enter a noun: | <input type="text" name="noun" /> |
Enter a noun: | <input type="text" name="noun" /> |
<input type="submit" value="Send parameters" /> </form> </body>
</html></source>