编写学生注册页面register.html,如图1所示。编写register.jsp,获取注册页面提交的内容,并通过out对象输出,运行结果如图2所示:
时间: 2024-03-13 07:44:17 浏览: 28
根据您的问题描述,我可以给出如下代码示例。首先是register.html页面的代码:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>学生注册</title>
</head>
<body>
<h1>学生注册</h1>
<form action="register.jsp" method="POST">
<label>学号:</label>
<input type="text" name="id"><br>
<label>姓名:</label>
<input type="text" name="name"><br>
<label>性别:</label>
<input type="radio" name="gender" value="male">男
<input type="radio" name="gender" value="female">女<br>
<label>年龄:</label>
<input type="number" name="age"><br>
<label>密码:</label>
<input type="password" name="password"><br>
<input type="submit" value="注册">
</form>
</body>
</html>
```
然后是register.jsp的代码:
```jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>学生注册结果</title>
</head>
<body>
<h1>学生注册结果</h1>
<%
String id = request.getParameter("id");
String name = request.getParameter("name");
String gender = request.getParameter("gender");
String age = request.getParameter("age");
String password = request.getParameter("password");
out.println("学号:" + id + "<br>");
out.println("姓名:" + name + "<br>");
out.println("性别:" + gender + "<br>");
out.println("年龄:" + age + "<br>");
out.println("密码:" + password + "<br>");
%>
</body>
</html>
```
在register.jsp中,我们首先使用request.getParameter()方法获取注册页面提交的参数值,然后使用out对象输出结果。
希望这个示例代码可以帮助您完成您的学生注册页面!
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)