1 .使用servlet+html完成答辩项目的登录功能
登录注册
packagecom.xiaocui.controller;
importjava.io.IOException;
importjava.util.Arrays;
importjavax.servlet.ServletException;
importjavax.servlet.annotation.WebServlet;
importjavax.servlet.http.HttpServlet;
importjavax.servlet.http.HttpServletRequest;
importjavax.servlet.http.HttpServletResponse;
/**
* Request
*/
@WebServlet("/RequestDemo1")
publicclassRequestDemo1extendsHttpServlet {
protectedvoiddoGet(HttpServletRequest request, HttpServletResponse response)throwsServletException, IOException {
String username = request.getParameter("username");
String password = request.getParameter("password");
String sex = request.getParameter("sex");
String city = request.getParameter("city");
String[] info = request.getParameterValues("info");
System.out.println("用户名" + username);
System.out.println("密码" + password);
System.out.println("性别" + sex);
System.out.println("自我介绍" + info);
}
protectedvoiddoPost(HttpServletRequest request, HttpServletResponse response)throwsServletException, IOException {
doGet(request, response);
}
}
<!DOCTYPE html>
<html>
<head>
"UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>网页登录</h1>
"/RequestDemo1">
用户名:"text"name="username">
密码:"password"name="password">
性别:"radio"name="sex"value="man">男
"radio"name="sex"value="woman">女
个人介绍:"3"cols="8"name="info">
"submit"value="提交">
是否确认登录?"checkbox"name=""id=""value=""/>
注册:"submit"id=""value="注册"/>
</form>
</body>
</html>