<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<title>注册页面</title>
</head>
<body>
<label for="name">用户名:</label>
<input type="text" id="username" />
<br/>
<label for="password">密码:</label>
<input type="text" id="password" />
<br/>
<label for="againPassword">确认密码:</label>
<input type="text" id="againPassword" />
<br/>
<!-- 下拉列表 -->>
<label for="country">国家:</label>
<select id="country">
<option value="China">中国</option>
<option value="USA">美国</option>
<option value="UK">英国</option>
</select>
<br/>
<input type="button" value="注册" onclick="regist()"/>
</body>
<script>
function regist(){
var username = $("#username").val();
var password = $("#password").val();
var againPassword = $("#againPassword").val();
var country = $("#country").val();
$.ajax({
typr:"get",
url:"/BigData02/RegistServlet",
data:{"username":username,"password":password,"againPassword":againPassword,"country":country},
success:function(data){
console.log(data);
}
})
}
</script>
</html>
package com.bigdata;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class RegistServlet
*/
@WebServlet("/RegistServlet")
public class RegistServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public RegistServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String username = request.getParameter("username");
String password = request.getParameter("password");
String againPassword = request.getParameter("againPassword");
String country = request.getParameter("country");
System.out.println(username + " " + password + " " + againPassword + " " + country);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
标签:username,HttpServlet,againPassword,用户名,Eclipse,request,country,Jee,password
From: https://blog.csdn.net/qq_73202167/article/details/136951084