From f2cf441592622c3d5047bfd641dc1b18926b7556 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E6=98=8E?= Date: Fri, 4 Mar 2022 14:55:33 +0800 Subject: [PATCH 1/4] =?UTF-8?q?[feat]=201.=20=E6=B5=8B=E8=AF=95=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=EF=BC=8C=E6=B7=BB=E5=8A=A0index=E6=96=87=E4=BB=B6=202?= =?UTF-8?q?.=20=E6=B7=BB=E5=8A=A0First=E7=9A=84Servlet=EF=BC=8C=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0servlet=E7=9A=84=E8=B0=83=E7=94=A8=203.=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9Web.xml=EF=BC=8C=E9=83=A8=E7=BD=B2first=20servlet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ming/First.java | 16 ++++++++++++++++ web/WEB-INF/web.xml | 14 ++++++++++++++ web/index.jsp | 16 ++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 src/ming/First.java create mode 100644 web/WEB-INF/web.xml create mode 100644 web/index.jsp diff --git a/src/ming/First.java b/src/ming/First.java new file mode 100644 index 0000000..e3c410d --- /dev/null +++ b/src/ming/First.java @@ -0,0 +1,16 @@ +package ming; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.Date; + +public class First extends HttpServlet { + + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { + response.setContentType("text/html;charset=utf-8"); + response.getWriter().write("Hello, first servlet
"); + response.getWriter().write("Date is:" + new Date()); + } +} diff --git a/web/WEB-INF/web.xml b/web/WEB-INF/web.xml new file mode 100644 index 0000000..0a30e38 --- /dev/null +++ b/web/WEB-INF/web.xml @@ -0,0 +1,14 @@ + + + + first + ming.First + + + first + /first + + \ No newline at end of file diff --git a/web/index.jsp b/web/index.jsp new file mode 100644 index 0000000..f5688e1 --- /dev/null +++ b/web/index.jsp @@ -0,0 +1,16 @@ +<%-- + Created by IntelliJ IDEA. + User: ming + Date: 2022/2/28 + Time: 10:57 + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + First Web + + + Hello World! + + -- Gitee From f956c026cc2dfe6e2b6cb478cc2a6a5bd5737c8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E6=98=8E?= Date: Fri, 4 Mar 2022 14:59:46 +0800 Subject: [PATCH 2/4] =?UTF-8?q?[fix]=201.=20=E6=B5=8B=E8=AF=95=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ming/First.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ming/First.java b/src/ming/First.java index e3c410d..4add97f 100644 --- a/src/ming/First.java +++ b/src/ming/First.java @@ -12,5 +12,6 @@ public class First extends HttpServlet { response.setContentType("text/html;charset=utf-8"); response.getWriter().write("Hello, first servlet
"); response.getWriter().write("Date is:" + new Date()); + response.getWriter().write("Hello test" + new Date()); } } -- Gitee From fc40d99f312e7412788a09c505cd632255cb3c16 Mon Sep 17 00:00:00 2001 From: csmaming Date: Mon, 7 Mar 2022 10:36:57 +0800 Subject: [PATCH 3/4] =?UTF-8?q?[feat]=201.=20=E5=A2=9E=E5=8A=A0=E6=89=93?= =?UTF-8?q?=E5=8D=B0Hello=20World=E7=9A=84=E8=AF=AD=E5=8F=A5=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/index.jsp | 1 + 1 file changed, 1 insertion(+) diff --git a/web/index.jsp b/web/index.jsp index f5688e1..b346381 100644 --- a/web/index.jsp +++ b/web/index.jsp @@ -12,5 +12,6 @@ Hello World! + Hello World! -- Gitee From 818d4c564064bcfcdb4ec5c10b99afc7a9f21370 Mon Sep 17 00:00:00 2001 From: csmaming Date: Mon, 7 Mar 2022 11:04:01 +0800 Subject: [PATCH 4/4] =?UTF-8?q?[feat]=201.=20=E6=B7=BB=E5=8A=A0=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E5=8A=9F=E8=83=BD=E3=80=82=202.=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=96=87=E4=BB=B6LoginServlet.java,=20login.jsp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ming/LoginServlet.java | 35 +++++++++++++++++++++++++++++++++++ web/WEB-INF/web.xml | 10 ++++++++++ web/login.jsp | 24 ++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 src/ming/LoginServlet.java create mode 100644 web/login.jsp diff --git a/src/ming/LoginServlet.java b/src/ming/LoginServlet.java new file mode 100644 index 0000000..4382f09 --- /dev/null +++ b/src/ming/LoginServlet.java @@ -0,0 +1,35 @@ +package ming; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.UnsupportedEncodingException; + +public class LoginServlet extends HttpServlet { + + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { + request.getRequestDispatcher("/login.jsp").forward(request,response); + + } + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { + request.setCharacterEncoding("UTF-8"); + response.setContentType("text/html;charset=utf-8"); + + String name = request.getParameter("name"); + String pw = request.getParameter("password"); + + if(pw.equals("123")) + { + System.out.println("登录成功"); + request.setAttribute("result", "登录成功,欢迎"+name); + } + else + { + System.out.println("登录失败"); + request.setAttribute("result", "登录失败,密码"+pw); + } + request.getRequestDispatcher("/login.jsp").forward(request,response); + } +} diff --git a/web/WEB-INF/web.xml b/web/WEB-INF/web.xml index 0a30e38..42c6401 100644 --- a/web/WEB-INF/web.xml +++ b/web/WEB-INF/web.xml @@ -11,4 +11,14 @@ first /first + + + login + ming.LoginServlet + + + + login + /login + \ No newline at end of file diff --git a/web/login.jsp b/web/login.jsp new file mode 100644 index 0000000..7a61b0c --- /dev/null +++ b/web/login.jsp @@ -0,0 +1,24 @@ +<%-- + Created by IntelliJ IDEA. + User: ming + Date: 2022/3/7 + Time: 上午10:40 + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Title + + + +

${result}

+ +
+ 用户名:
+ 密码:
+ +
+ + + -- Gitee