zoukankan      html  css  js  c++  java
  • Servlet的登录验证

    index.jsp:

    <%--
      Created by IntelliJ IDEA.
      User: admin
      Date: 2019/10/15
      Time: 11:16
      To change this template use File | Settings | File Templates.
    --%>
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <html>
    <head>
        <title>Servlet登录界面</title>
    </head>
    <body>
    <form action="<%=request.getContextPath()%>/demo"method="post">
    
        <table align="center">
            <tr><td>
                账号姓名: <input type="text"name="userName"placeholder="请输入账号姓名"><br><br>
                密码: &nbsp;&nbsp;&nbsp; <input type="password"name="password"placeholder="请输入密码"><br><br>
                <input type="submit"value="登录">
    
            </td></tr>
        </table>
    </form>
    
    
    </body>
    </html>

    shibai.jsp:

    <%--
      Created by IntelliJ IDEA.
      User: admin
      Date: 2019/10/15
      Time: 11:23
      To change this template use File | Settings | File Templates.
    --%>
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <html>
    <head>
        <title>Servlet登录失败页面</title>
        <style>
            h1{
                color: red;
            }
        </style>
    </head>
    <body>
    
    <h1>登录失败</h1>
    
    </body>
    </html>

    success.jsp:

    <%--
      Created by IntelliJ IDEA.
      User: admin
      Date: 2019/10/15
      Time: 11:22
      To change this template use File | Settings | File Templates.
    --%>
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <html>
    <head>
        <title>Servlet登录成功页面</title>
        <style>
            h1{
                color: green;
            }
        </style>
    </head>
    <body>
    
    <h1>登录成功</h1>
    </body>
    </html>

    表单验证:

    MyServlet:

    <%--
      Created by IntelliJ IDEA.
      User: admin
      Date: 2019/10/15
      Time: 11:22
      To change this template use File | Settings | File Templates.
    --%>
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <html>
    <head>
        <title>Servlet登录成功页面</title>
        <style>
            h1{
                color: green;
            }
        </style>
    </head>
    <body>
    
    <h1>登录成功</h1>
    </body>
    </html>

    pojo中User类:

    package pojo;
    
    import javax.servlet.http.HttpSessionBindingEvent;
    import javax.servlet.http.HttpSessionBindingListener;
    
    public class User{
        private String userName;
        private String password;
    
    
        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;
        }
    }
  • 相关阅读:
    java进程占用CPU高的问题
    上下文切换的案例以及CPU使用率
    百度地图sdk问题 error inflating class com.baidu.mapapi.map.mapview
    Android APK反编译
    Binary XML file line #17<vector> tag requires viewportWidth > 0
    用代码实现签名
    百度地图出现UnsatisfiedLinkError: Native method not found: com.baidu...
    INSTALL_FAILED_INVALID_APK
    Android package属性、package name和Application ID三者的联系及区别
    Android使用百度定位API时获取的地址信息为null
  • 原文地址:https://www.cnblogs.com/bichen-01/p/11676619.html
Copyright © 2011-2022 走看看