二个案例采用了Servlect,Filter,Listener。
运行结果图
创建项目 如上图所示
代码:
package com.DengLu.And.Zhu.Ce; import java.io.IOException; import java.io.PrintWriter; import java.util.Random; 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 ServlectDengLuLose */ @WebServlet("/ServlectDengLuLose") public class DengLuChengGong extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public DengLuChengGong() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setCharacterEncoding("UTF-8"); response.setContentType("text/html"); response.setHeader("refresh", "5"); //设置要求浏览器 /* response.sendRedirect("Servlet1"); */ int i=(int)(Math.random()*900000+100000); int a=(int)(Math.random()*9000+1000); int c=(int)(Math.random()*900+100); System.out.println("@@@@"+(new Random().nextInt(900000)+100000)); /* * 设置随机 */ System.out.println(new Random().nextInt(100)); System.out.println(Math.random()); PrintWriter pw =response.getWriter(); pw.print("你的支付宝到账1000万元,需要的码号为:<h1 style='color:red ;background-color:green'>"+i+"</h1>,打死也不说 \"<hr>\";"); pw.print("你的QQ到账1000万元,需要的码号为:<h2 style='color:red ;background-color:green'>"+c+"</h2>,打死也不说 \"<hr>\";"); pw.print("你的微信到账1000万元,需要的码号为:<span style='color:green'>"+a+"</span>,打死也不说"); pw.print("你的手机支付宝到账1000万<span style='color :red'>"+i+"</span>"); pw.append("<style>"); pw.append(" *{\r\n" + " margin: 0px;\r\n" + " padding: 0px;\r\n" + " background: white;\r\n" + " font-size: 30px;\r\n" + " font-weight: bold;\r\n" + " text-shadow: 5px 5px 5px red;\r\n" + "\r\n" + " }"); pw.append("</style>"); pw.append("<h1 align ='center'>2021你年垮2022年QQ登陆失败的界面</h1>"); pw.append("登陆界面失败请重新登陆"); response.setHeader("refresh","5;URL=Register.jsp"); pw.append("<h2 align ='center'><a href='ServlectDengLu'>点击这里返回登陆界面进行重新登陆</a></h2>"); pw.append("如果用户一分钟后没有任何操作则在60秒后调到index.jsp文件"); response.setHeader("refresh","60;URL=insex.jsp"); } /** * @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); } }
package com.DengLu.And.Zhu.Ce; import java.io.IOException; import java.io.PrintWriter; import java.util.Random; import javax.servlet.ServletContext; 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 ServlectDengLuLogic */ @WebServlet("/ServlectDengLuLogic") public class ServlectDengLuLogic extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public ServlectDengLuLogic() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { /** * do--post */ response.setContentType("text/html"); response.setCharacterEncoding("UTF-8"); ServletContext sc=getServletContext(); //获取web.xml文件中的镜头数据 String a=sc.getInitParameter("USER"); String b=sc.getInitParameter("PSD"); System.out.println(a+"@@@@@@@@"+b); response.getWriter().append("ServletB获得静态数据用来访问web.xml"+a); String aa=request.getParameter("user"); String bb=request.getParameter("psd"); //不区分大小写equalsIgnoreCase(aa) if(a.equalsIgnoreCase(aa)&&b.equalsIgnoreCase(bb)) { //重定向跳转页面 System.out.println("登录成功跳转到2021登录成功"); response.sendRedirect("HomeServlect2"); }else { System.out.println("登录失败五秒后返回Register.jsp"); response.sendRedirect("Register.jsp"); } } }
package com.DengLu.And.Zhu.Ce; import java.io.IOException; import java.io.PrintWriter; 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 ServlectDengLuLose */ @WebServlet("/DengLuChengGong") public class ServlectDengLuLose extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public ServlectDengLuLose() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); response.setCharacterEncoding("utf-8"); PrintWriter pw = response.getWriter(); pw.append("<h1>欢迎你成功登录2021-2022年的QQ登录页面</h1>"); pw.append(" *{\r\n" + " margin: 0px;\r\n" + " padding: 0px;\r\n" + " background: white;\r\n" + " font-size: 40px;\r\n" + " font-weight: bold;\r\n" + " text-shadow: 5px 5px 5px red;\r\n" + " background: pink;" + ""); response.setHeader("refresh","60;URL=Register.jsp"); } /** * @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); } }
package com.DengLu.And.Zhu.Ce; import java.io.IOException; import javax.servlet.ServletContext; 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 ServlectZhuCeLogic */ @WebServlet("/ServlectZhuCeLogic") public class ServlectZhuCeLogic extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public ServlectZhuCeLogic() { super(); System.out.println("2021你年垮2022年QQ注注册界面logic的判断"); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub response.getWriter().append("Served at: ").append(request.getContextPath()); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // dopost response.setContentType("text/html"); response.setCharacterEncoding("UTF-8"); ServletContext sc=getServletContext(); //获取web.xml文件中的镜头数据 String a=sc.getInitParameter("USER"); String b=sc.getInitParameter("QQ"); String c=sc.getInitParameter("PSD"); String d=sc.getInitParameter("SJ"); System.out.println(a+"#"+b+"#"+c+"#"+d); response.getWriter().append("<h2>ServlectZhuCeLogic获得静态数据用来访问name:</h2>"+a); //获得浏览器数据 String aa=request.getParameter("user"); String bb=request.getParameter("qq"); String cc=request.getParameter("psd"); String dd=request.getParameter("sj"); /* System.out.println(aa+":"+bb+":"+cc); */ //不区分大小写equalsIgnoreCase(aa) if(a.equalsIgnoreCase(aa)&&b.equalsIgnoreCase(bb)&&c.equalsIgnoreCase(cc)&&d. equalsIgnoreCase(dd)) { //重定向跳转页面 System.out.println("登录成功跳转到ServlectDengLu"); response.sendRedirect("Login.jsp"); }else { System.out.println("登录失败五秒后返回ServlectZhuCeLose"); response.sendRedirect("ServlectZhuCeLose"); } } }
package com.DengLu.And.Zhu.Ce; import java.io.IOException; import java.io.PrintWriter; 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 ServlectZhuCeLose */ @WebServlet("/ServlectZhuCeLose") public class ServlectZhuCeLose extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public ServlectZhuCeLose() { super(); System.out.println("请重新注册没有成功哦"); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); response.setCharacterEncoding("utf-8"); PrintWriter pw = response.getWriter(); pw.append("<style>"); pw.append(" *{\r\n" + " margin: 0px;\r\n" + " padding: 0px;\r\n" + " background: white;\r\n" + " font-size: 30px;\r\n" + " font-weight: bold;\r\n" + " text-shadow: 5px 5px 5px red;\r\n" + "\r\n" + " }"); pw.append("</style>"); pw.append("<h1 align ='center'>2021你年垮2022年QQ注册失败的界面</h1>"); pw.append("<h1 align ='center' style='color;red';background:green>2021你年垮2022年QQ注注册界面失败请重新注册</h1>"); pw.append("<h2 align ='center'>五秒后自动返回注册页面</h2>"); response.setHeader("refresh","5;URL=Register.jsp"); } /** * @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); } }
package com.Filter; import java.io.IOException; import java.io.OutputStream; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; public class MyFilter4 implements Filter{ public MyFilter4() { // TODO Auto-generated constructor System.out.println("我创建了第一个MyFilter过滤器"); } @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { response.setContentType("text/html"); response.setCharacterEncoding("UTF-8"); System.out.println("我是myfilter开始拦截请求地址哦哦"); } @Override public void init(FilterConfig config) throws ServletException { // TODO Auto-generated method stub System.out.println("FilterConfig用来加载初始化数据"); } @Override public void destroy() { System.out.println("Filter所有方法运行完毕后销毁过滤器"); } } package com.Listener; /** * 第三类接口 */ import javax.servlet.http.HttpSessionBindingEvent; import javax.servlet.http.HttpSessionBindingListener; public class Listener implements HttpSessionBindingListener { private int id; private String username; private String password; public Listener() { // TODO Auto-generated constructor stub } public Listener(int id, String username, String password) { super(); this.id = id; this.username = username; this.password = password; } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } @Override public String toString() { return "Listener [id=" + id + ", username=" + username + ", password=" + password + ", getId()=" + getId() + ", getUsername()=" + getUsername() + ", getPassword()=" + getPassword() + ", getClass()=" + getClass() + ", hashCode()=" + hashCode() + ", toString()=" + super.toString() + "]"; } @Override public void valueBound(HttpSessionBindingEvent event) { // TODO Auto-generated method stub System.out.println("HttpSession 与 Listener绑定"); HttpSessionBindingListener.super.valueBound(event); } @Override public void valueUnbound(HttpSessionBindingEvent event) { // TODO Auto-generated method stub System.out.println("HttpSession 与 Listener解绑绑"); HttpSessionBindingListener.super.valueUnbound(event); } }
package com.Servlect; import java.io.IOException; import java.io.PrintWriter; 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 HomeServlect2 */ @WebServlet("/HomeServlect2") public class HomeServlect2 extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public HomeServlect2() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub //response.getWriter().append("Served at: ").append(request.getContextPath()); response.setContentType("text/html"); response.setCharacterEncoding("UTF-8"); PrintWriter pw =response.getWriter(); pw.append("<h1 style='color:red'>登录成功</h1>"); pw.append("<h1><a href='ServlectOne'>返回主界面</a></h1>"); } /** * @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); } } package com.Servlect; import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.annotation.WebFilter; /** * Servlet Filter implementation class MyFilter1 */ //你要阻止Servlect2 @WebFilter("/Servlect2") public class MyFilter1 implements Filter { /** * Default constructor. */ public MyFilter1() { // TODO Auto-generated constructor stub System.out.println("构造方法"); } /** * @see Filter#destroy() */ public void destroy() { // TODO Auto-generated method stub System.out.println("销毁数据"); } /** * @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain) */ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { response.setContentType("text/html"); response.setCharacterEncoding("UTF-8"); System.out.println("我是myfilter1开始拦截请求地址哦哦"); //实施访问 chain.doFilter(request, response); } /** * @see Filter#init(FilterConfig) */ public void init(FilterConfig fConfig) throws ServletException { // TODO Auto-generated method stub System.out.println("加载数据"); } } package com.Servlect; /** * A202020895 * 10/29 * */ import java.io.IOException; import java.io.PrintWriter; import java.net.URLDecoder; import java.net.URLEncoder; import java.util.Random; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * Servlet implementation class Servlet1 */ @WebServlet("/Servlet1") public class servlect1 extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public servlect1() { super(); System.out.println("servlect在运行中使用cookie访问"); // TODO Auto-generated constructor stub } @Override public void init() throws ServletException { // TODO Auto-generated method stub super.init(); System.out.println("servlectinit方法"); } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); response.setCharacterEncoding("UTF-8"); /* response.sendRedirect("Servlet1"); */ int i=(int)(Math.random()*900000+100000); int a=(int)(Math.random()*9000+1000); int c=(int)(Math.random()*900+100); System.out.println("@@@@"+(new Random().nextInt(900000)+100000)); /* * 设置随机 */ System.out.println(new Random().nextInt(100)); System.out.println(Math.random());
package com.Servlect; import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.annotation.WebFilter; /** * Servlet Filter implementation class MyFilter1 */ //你要阻止Servlect2 @WebFilter("/Servlect2") public class MyFilter1 implements Filter { /** * Default constructor. */ public MyFilter1() { // TODO Auto-generated constructor stub System.out.println("构造方法"); } /** * @see Filter#destroy() */ public void destroy() { // TODO Auto-generated method stub System.out.println("销毁数据"); } /** * @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain) */ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { response.setContentType("text/html"); response.setCharacterEncoding("UTF-8"); System.out.println("我是myfilter1开始拦截请求地址哦哦"); //实施访问 chain.doFilter(request, response); } /** * @see Filter#init(FilterConfig) */ public void init(FilterConfig fConfig) throws ServletException { // TODO Auto-generated method stub System.out.println("加载数据"); }
package com.Servlect; /** * A202020895 * 10/29 * */ import java.io.IOException; import java.io.PrintWriter; import java.net.URLDecoder; import java.net.URLEncoder; import java.util.Random; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * Servlet implementation class Servlet1 */ @WebServlet("/Servlet1") public class servlect1 extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public servlect1() { super(); System.out.println("servlect在运行中使用cookie访问"); // TODO Auto-generated constructor stub } @Override public void init() throws ServletException { // TODO Auto-generated method stub super.init(); System.out.println("servlectinit方法"); } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); response.setCharacterEncoding("UTF-8"); /* response.sendRedirect("Servlet1"); */ int i=(int)(Math.random()*900000+100000); int a=(int)(Math.random()*9000+1000); int c=(int)(Math.random()*900+100); System.out.println("@@@@"+(new Random().nextInt(900000)+100000)); /* * 设置随机 */ System.out.println(new Random().nextInt(100)); System.out.println(Math.random()); PrintWriter pw =response.getWriter(); pw.print("你的支付宝到账1000万元,需要的码号为:<h1 style='color:red ;background-color:green'>"+i+"</h1>,打死也不说 \"<hr>\";"); pw.print("你的QQ到账1000万元,需要的码号为:<h2 style='color:red ;background-color:green'>"+c+"</h2>,打死也不说 \"<hr>\";"); pw.print("你的微信到账1000万元,需要的码号为:<span style='color:green'>"+a+"</span>,打死也不说"); pw.print("你的手机支付宝到账1000万<span style='color :red'>"+i+"</span>"); //浏览器通过地址访问服务器的servelt //servlet要获得该浏览器所携带的所有cookie对象 Cookie[] cookies=request.getCookies(); if (cookies!=null) { //循环遍历每一个cookie,直到找到servlet能识别的cookie值为止 //tag,china for (int e = 0; e < cookies.length; e++) { //通过cookie中存储的数据的名称 String name=cookies[i].getName(); if ("AAA".equals(name)) { //这个cookie是服务器要找的东西,从cookie中获得中文数据需要进行解码 String value=URLDecoder.decode(cookies[e].getValue(), "UTF-8"); System.out.println(value); pw.print(value); break; } } }else { //没有cookie,说明当前浏览器以前没有访问过服务器 //创建cookie对象,存储中文数据的时候,需要对数据进行转码 Cookie cookie=new Cookie("AAA", URLEncoder.encode("bbbbbbbb", "UTF-8")); //设置浏览器退出后,cookie还能继续存在内存中的时间 cookie.setMaxAge(30); response.addCookie(cookie); pw.print("服务器给浏览器创建了一个cookie对象"); } } /** * @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); } }
package com.Servlect; /** * 这一个类让我们去了解Servlect的周期 */ import java.io.IOException; import javax.servlet.Servlet; import javax.servlet.ServletConfig; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; public class ServlectOne implements Servlet{ public ServlectOne() { // TODO Auto-generated constructor stub System.out.println("@1 Servlec方法的构造方法"); } @Override public void destroy() { System.out.println("@2 Servlect方法的销毁"); } @Override public ServletConfig getServletConfig() { // TODO Auto-generated method stub System.out.println("@ 3Servlect方法加载静态数据"); return null; } @Override public String getServletInfo() { // TODO Auto-generated method stub System.out.println("@ 4 Servlect的getServletInfo方法"); return null; } @Override public void init(ServletConfig config) throws ServletException { // 获取静态数据的对象 String a=config.getInitParameter("SFZ"); System.out.println(a); System.out.println("@5 Servlecto的init方法"); System.out.println("获取静态数据的对象config"); //动态数据的获取 } @Override public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException { // TODO Auto-generated method stub System.out.println("@5 Servlecto的servlect方法"); } }
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <style> *{ text-align: center; align-content: center; margin: 30px; font-size: 30px; background:lightskyblue; font-weight: 700; font-family: "微软雅黑"; padding: 2px; color: red; } article{ } </style> <title>登录页面</title> </head> <body> <article> <h1>欢迎来到2021年个人QQ登录界面</h1> <form action="ServlectDengLuLogic" method=""> <img src="img/aq (4).png" style="border-radius: 70%; height: 200px;"/> QQ号:<input type='text' name='qq'><br> 密码:<input type='password' name='psd'><br> <input type='checkbox' value='flase' checked='checked' name='ispsd'>记住密码 <input type='checkbox' value='true' name='islogin'>自动登录<br> <input type='submit' value='登录'><br> </form> </article> </body> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <style type="text/css"> * { margin: 0; padding: 0; background: cornflowerblue; } body { background-color: #ffffff; } li { list-style: none; } left { width: 480px; float: left; } .header { width: 1040px; height: 100px; float: right; } .top { float: right; } .main { width: 500px; margin: 0 auto; } .one h1 { font-size: 46px; font-weight: 400; margin-bottom: 20px; } .two { font-size: 28px; color: #333333; margin-bottom: 64px; float: left; } .there { float: right; margin-bottom: 64px; } .there a { font-size: 28px; text-decoration: none; color: #359eff; } .there a:hover { color: #094683; } .input-outer input { height: 50px; width: 438px; margin-bottom: 40px; border-radius: 10px; border: 1px solid #c1c1c1; color: #c1c1c1; font-size: 20px; } .input-outer span, .input-phone span { font-size: 25px; text-align: center; line-height: 50px; color: #333333; } .input-type select { margin: auto; height: 50px; border-radius: 10px; border: 1px solid #c1c1c1; font-size: 20px; float: left; } .input-phone input { height: 50px; width: 268px; border-radius: 10px; border: 1px solid #c1c1c1; font-size: 20px; margin-left: 20px; } .input-qq input { height: 50px; width: 268px; border-radius: 10px; border: 1px solid #c1c1c1; font-size: 20px; margin-left: 20px; } .six p { color: #c1c1c1; font-size: 14px; } .sub input { align-content: center; text-align: center; height: 50px; width: 440px; margin: 40px 0; font-size: 20px; color: #ffffff; background-color: #3588ff; border: 1px solid #c1c1c1; border-radius: 10px; } .type-radio span { align-content: center; text-align: center; font-size: 14px; color: #c1c1c1; } .footer { align-content: center; text-align: center; margin: 40px 0; text-align: center; color: #c1c1c1; } h1{ text-shadow: 5px 5px 5px red; } </style> <title>注册页面</title> </head> <body> <h1 style="background: aquamarine; color: red; font-weight: 900; text-align: center;">欢迎来到2021年个人QQ注册界面</h1> <article style="text-align: center; align-content: center; text-align: center;"> <form action="ServlectZhuCeLogic" method="post"> <img src="img/aq (3).png" style="border-radius: 89%%;" height="200px" align="center"/> <div class="input-outer"> <h1>呢称:</h1><br><input type="text" name="user" id="text" maxlength="8"> </div> <div class="input-qq"> <h1>QQ号:</h1><br><input type="text" name="qq" maxlength="11" minlength="11"> </div> <div class="input-outer"> <h1>密码 :</h1><br><input type="password" name="psd" id="password" maxlength="16"> </div> <div class="input-phone"> <h1>手机号:</h1><br><input type="text" name="sj" maxlength="11" minlength="11" > </div> <div class="six"> <p>可通过手机号找回密码</p> </div> </div> <div class="sub"> <input type="submit" value="立即注册"> </div> </form> </article> <div class="type-radio"> <input type="radio" checked><span style="text-align: center;">同意开通QQ空间</span> <br> <input type="radio" checked><span style="text-align: center;">我已阅读并同意相关服务条款和隐私政策开始进行登录QQ页面</span> </div> <div> <footer> <h1>这是QQ的注册页面</h1> </footer> </div> </div> </div> </body> </html>
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0"> <display-name>QQLoginD</display-name> <welcome-file-list> <welcome-file>LoginServlect</welcome-file> <welcome-file>Register.jsp</welcome-file> </welcome-file-list> <servlet> <servlet-name>ServlectOne</servlet-name> <servlet-class>com.Servlect.ServlectOne</servlet-class> <init-param> <param-name>SFZ</param-name> <param-value>360429100056781234</param-value> </init-param> </servlet> <context-param> <param-name>LQ</param-name> <param-value>篮球</param-value> </context-param> <servlet-mapping> <servlet-name>ServlectOne</servlet-name> <url-pattern>/ServlectOne</url-pattern> </servlet-mapping> <!--过滤器的注册 --> <filter> <filter-name>MyFilter4</filter-name> <filter-class>com.Filter.MyFilter4</filter-class> </filter> <filter-mapping> <filter-name>MyFilter4</filter-name> <!-- 这表示可以拦截任何请求 --> <url-pattern>/Servlect1</url-pattern> </filter-mapping> <!--listener的注册 --> <listener> <listener-class>com.Listener.Listener</listener-class> </listener> <context-param> <param-name>USER</param-name> <param-value>hug</param-value> </context-param> <context-param> <param-name>QQ</param-name> <param-value>123456</param-value> </context-param> <context-param> <param-name>PSD</param-name> <param-value>123456</param-value> </context-param> <context-param> <param-name>SJ</param-name> <param-value>18172928419</param-value> </context-param> </web-app>