<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <style> img{500px; height:200px} div{ margin:0 auto; 500px; height:550px;} </style> <body> <div> <p><img alt="图片" src="img/1.jpg" ></p> <form action="gain.jsp" method="post"> <p> 账号:<input type="text" name="userName" /> </p> <p> 密码:<input type="password" name="userpass" /> </p> <p> 性别:<input name="sex" type="radio" value="男" />男 <input name="sex" type="radio" value="女" />女 </p> <p> 兴趣爱好:<input name="like" type="checkbox" value="篮球" />篮球 <input name="like" type="checkbox" value="敲代码" />敲代码 <input name="like" type="checkbox" value="玩游戏" />玩游戏 <input name="like" type="checkbox" value="听音乐" />听音乐 </p> <p> <input type="submit" value="注册" /> <input type="reset" value="重置" /> </p> </form> </div> </body> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> <% request.setCharacterEncoding("UTF-8"); String name = request.getParameter("userName"); String pass = request.getParameter("userpass"); String sex = request.getParameter("sex"); String[] love = request.getParameterValues("like"); %> <p>用户名:<%=name %></p> <p>密码:<%=pass %></p> <p>性别:<%=sex %></p> <p>兴趣爱好:<%if(love!=null){ for(String loves:love){ out.print(loves); }} %></p> </body> </html>