reginput
<%@ page language="java" contentType="text/html; charset=UTF-8"%> <html> <head> <title>学员注册</title> </head> <body> <div align="center">请输入注册信息 <form name="form1" method="post" action="reginfo.jsp"> <table border="0" align="center"> <tr> <td>用户名:</td> <td><input type="text" name="name"></td> </tr> <tr> <td height="19">密码:</td> <td height="19"><input type="password" name="pwd"></td> </tr> <tr> <td>信息来源:</td> <td> <input type="checkbox" name="channel" value="报刊">报刊 <input type="checkbox" name="channel" value="网络">网络 <input type="checkbox" name="channel" value="朋友推荐">朋友推荐 <input type="checkbox" name="channel" value="电视">电视 </td> </tr> <!-- 以下是提交、取消按钮 --> <tr> <td colspan=”2” align=”center”> <input type="submit" name="Submit" value="提交"> <input type="reset" name="Reset" value="取消"> </td> </tr> </table> </form> </div> </body> </html>
?
reginfo
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <% request.setCharacterEncoding("utf-8"); String name = request.getParameter("name"); String pwd = request.getParameter("pwd"); String[] channels = request.getParameterValues("channel"); %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>注册信息</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> </head> <body> <div align="center"> 您输入的注册信息 <table border="0" align="center"> <tr> <td> 用户名: </td> <td> <%=name%> </td> </tr> <tr> <td height="20"> 密码: </td> <td height="20"> <%=pwd %> </td> </tr> <tr> <td> 信息来源: </td> <td> <% if(channels != null){ for(int i = 0; i<channels.length; i++){ out.print(channels[i]+" "); } } %> </td> </tr> </table> </div> </body> </html>
?
效果图:
?
?