| |
23. 23. 3. TextField的处理,表格和选项 |
|
index.jsp |
<html>
<head>
<title>Simple Form Example</title>
</head>
<body>
<center>
<form action="simpleForm.jsp">
<table>
<tr>
<td>Name: </td>
<td><input type="Text" name="name"/></td>
</tr>
<tr>
<td>Occupation: </td>
<td><input type="Text" name="job"/></td>
</tr>
<tr>
<td>Hobbies: </td>
<td>
<select name="hobbies" multiple size="5">
<option value="Sports">Sports</option>
<option value="Cooking">Cooking</option>
<option value="Camping">Camping</option>
<option value="Reading">Reading</option>
<option value="Music">Music</option>
</select>
</td>
</tr>
</table>
<input type="submit" value="submit"/>
</form>
</center>
</body>
</html>
|
|
simpleForm.jsp |
<html>
<head>
<title>Simple Form Example</title>
</head>
<body>
Hello <%= request.getParameter("name") %>.<br><br>
It must be very interesting being employed as a <%= request.getParameter("job") %>.<br><br>
I see you enjoy the following hobbies: <br><br>
<%
String hobbies[] = request.getParameterValues("hobbies");
for (int n = 0; n < hobbies.length; n++) {
%>
<%= hobbies[n] %> <br>
<%
}
%>
</body>
</html>
|
|
Download: JSPDealWithFormTextFieldAndSelect.zip( 4 k) |
|