File tree Expand file tree Collapse file tree
JavaWeb/WebContent/Jsp9Objects Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html >
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < title > request_demo_02</ title >
6+ </ head >
7+ < body >
8+ < form action ="../JSP/request_demo02.jsp " method ="post ">
9+ 姓名:< input type ="text " name ="uname "> < br >
10+ 兴趣:< input type ="checkbox " name ="inst " value ="唱歌 "> 唱歌
11+ < input type ="checkbox " name ="inst " value ="跳舞 "> 跳舞
12+ < input type ="checkbox " name ="inst " value ="游泳 "> 游泳
13+ < input type ="checkbox " name ="inst " value ="看书 "> 看书
14+ < input type ="checkbox " name ="inst " value ="旅游 "> 旅游
15+ < input type ="hidden " name ="id " value ="3 "> <!-- 定义隐藏域 -->
16+ < br > < input type ="submit " value ="提交 ">
17+ < input type ="reset " value ="重置 ">
18+
19+ </ form >
20+ </ body >
21+ </ html >
Original file line number Diff line number Diff line change 1+ <%@ page language =" java" contentType =" text/html; charset=UTF-8"
2+ pageEncoding =" UTF-8" %>
3+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" >
4+ <html >
5+ <head >
6+ <meta http-equiv =" Content-Type" content =" text/html; charset=UTF-8" >
7+ <title >request_demo02</title >
8+ </head >
9+ <body >
10+ <%
11+ request. setCharacterEncoding(" UTF-8" );
12+ String id = request. getParameter(" id" );// 隐藏域的作用?此处的作用是接收隐藏域提交的参数
13+ String name = request. getParameter(" uname" );// 接收文本框提交的参数
14+ String inst[] = request. getParameterValues(" inst" );// 获取复选框提供的参数
15+ % >
16+ <h3 >
17+ 编号:<%= id % > </h3 >
18+ <h3 >
19+ 姓名:<%= name % > </h3 >
20+ <%
21+ if (inst != null ) {
22+ % >
23+ <h3 >
24+ 兴趣:
25+ <%
26+ for (int x = 0 ; x < inst. length; x++ ) {
27+ % >
28+ <%= inst[x] % >
29+ <%
30+ }
31+ % >
32+ </h3 >
33+ <%
34+ }
35+ % >
36+ </body >
37+ </html >
You can’t perform that action at this time.
0 commit comments