註冊頁面: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> <style> span{ display:inline-block; width:120px;font:bold 20px '楷體';} #d1{ text-align: center;} </style> </head> <body style="background-image:url(img/1.jpg);background-size: cover;padding: 0;margin: 0"> <div id="d1" style="color: white;"> <h2 style="color:gray; font:italic bold 36px '楷體';background: #fff1ff;border: 1px #fff1ff solid;width: 40%;margin: auto;">註冊頁面</h2> <form action="register.jsp" method="post" style="margin:5px 0 0 5px;"> <p><span>姓名:</span><input type="text" name="userName" placeholder="請輸入姓名" required pattern="[\u4E00-\u9FA5A-Za-z]+"/></p> <p><span>手機號:</span><input type="text" name="userPhone" placeholder="請輸入手機號" required="required" pattern="1[34578]\d{9}"/></p> <p><span>密碼:</span><input type="password" name="userPwd" required placeholder="長度爲6-16個字符" pattern="[a-zA-Z0-9]{6,16}" /></p> <p><span>郵箱:</span><input type="email" name="userEmail" placeholder="請輸入正確郵箱" required="required" pattern="\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}"/></p> <p><span>性別:</span> <input type="radio" name="sex" value="男"/>男 <input type="radio" name="sex" value="女"/>女 </p> <p><span>興趣愛好:</span> <input type="checkbox" name="hobby" value="籃球"/>籃球 <input type="checkbox" name="hobby" value="看書"/>看書 <input type="checkbox" name="hobby" value="看電影"/>看電影 <input type="checkbox" name="hobby" value="LOL"/>LOL </p> <p><span>出生日期:</span> <input type="date" name="date" /> </p> <p style="text-align: center;"> <input type="submit" value="提交" Style="border-radius: 26%;color: blue; height: 55px;width: 90px;font-size: 36px;font-family: '楷體'"/> <input type="reset" value="重置" Style="border-radius: 26%;color: blue;"/> </p> </form> </div> <div> <img alt="" src="img/3.jpg" width="35%" style="margin:o;opacity: 0.3;"> </div> </body> </html>
頁面效果:java
接受頁面:jsp
<%@ 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 style="background-image: url(img/2.jpg);padding: 0;margin: 0;text-align: center;font:bold 36px '楷體';color: red; "> <h1 style="color: blue">用戶註冊信息</h1> <%request.setCharacterEncoding("UTF-8"); %> <%String username=request.getParameter("userName"); %> <P><%out.print("用戶名:"+username); %><P/> <%String userPwd=request.getParameter("userPwd"); %> <p><%out.print("用戶密碼:"+userPwd); %><p/> <%String userEmail=request.getParameter("userEmail"); %> <p><%out.print("用戶郵箱:"+userEmail); %><p/> <%String userSex = request.getParameter("sex"); %> <p><%out.print("用戶性別:"+userSex); %><p/> <%String[] hobbys=request.getParameterValues("hobby"); %> <p>興趣愛好: <%if(hobbys!=null){ for(String hobby:hobbys){ out.print(hobby+"\t"); } } %> </p> <P>出生日期:<%String birthday=request.getParameter("date"); %> <%=birthday %> <P/> </body> </html>
頁面效果:post