JSP註冊頁面

宋春赫發表於2020-10-01
<%@ 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>
<%-- 註冊頁面 --%>
<h1>註冊新使用者</h1>
<form action="userService.jsp" method="get">
<table>
<tr>
	<td>使用者名稱: </td>
	<td><input type="text" name="username"></td>
</tr>
<tr>
	<td>密碼: </td>
	<td><input type="password" name="userpwd"></td>
</tr>
<tr>
	<td>愛好: </td>
	<td><input type="checkbox" name="hobby" value="1">科比
		<input type="checkbox" name="hobby" value="2">韋德
		<input type="checkbox" name="hobby" value="3">MJ
	</td>
</tr>
<tr>
<td><input type="submit"></td>
</tr>
</table>
</form>
</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>
<%-- 處理註冊 --%>
<%
String username=request.getParameter("username");//獲取請求引數
String userpwd=request.getParameter("userpwd");
out.print(username);
out.print(userpwd);
String[] hobbies=request.getParameterValues("hobby");
for(String str:hobbies){
	out.print(str);
}
%>
</body>
</html>

相關文章