2024/02/16

<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<html>
<head>
    <title>JSP - Hello World</title>
</head>
<div style="text-align: center">

    <h1> 登录界面</h1><br>
    <form method="post" id="login" action="login-servlet">
        用户身份:<select name="role" id="cars">
        <option value="school">研究生院校</option>
        <option value="stu" selected>学生</option>
        <option value="teacher">老师</option>
    </select><br>
        账号:<input type="text" name="id" id="nameid"><br><br>
        密码:<input type="password" name="pwd" id="pwd"><br><br>
        <span id="msg" style="font-size: 12px;color:red">${msg}</span><br>
        <button type="button" id="btm">登录</button>&emsp;
        <br>
    </form>


    <script>
        document.getElementById("btm").addEventListener("click", function(){
            var id=document.getElementById("nameid").value;
            var pwd=document.getElementById("pwd").value;
            if(!is(id))
            {
                document.getElementById('msg').innerHTML="您的账号不能为空";
                return;
            }
            if(!is(pwd))
            {
                document.getElementById('msg').innerHTML="您的密码不能为空";
                return;
            }
            document.getElementById('login').submit();
        });
        function is(s)
        {
            if (s.length==0||s.trim()=="")
                return false;
            else return true;
        }
    </script>
</div>
</body>
</html>
package bean;

public class LiuShui {
    private String schoolid;
    private String stuid;
    private String teaid;
    private String is1;
    private String is2;
    private String name;

    public String getZhuanye() {
        return zhuanye;
    }

    public void setZhuanye(String zhuanye) {
        this.zhuanye = zhuanye;
    }

    public String getZongfen() {
        return zongfen;
    }

    public void setZongfen(String zongfen) {
        this.zongfen = zongfen;
    }

    public String getMath() {
        return math;
    }

    public void setMath(String math) {
        this.math = math;
    }

    public String getEnglish() {
        return english;
    }

    public void setEnglish(String english) {
        this.english = english;
    }

    public String getZy() {
        return zy;
    }

    public void setZy(String zy) {
        this.zy = zy;
    }

    private String zhuanye;
    private String zongfen;
    private String math;
    private String english;
    private String zhengzhi;
    private String zy;
    public String getSchoolid() {
        return schoolid;
    }

    public void setSchoolid(String schoolid) {
        this.schoolid = schoolid;
    }

    public String getStuid() {
        return stuid;
    }

    public void setStuid(String stuid) {
        this.stuid = stuid;
    }

    public String getTeaid() {
        return teaid;
    }

    public void setTeaid(String teaid) {
        this.teaid = teaid;
    }

    public String getIs1() {
        return is1;
    }

    public void setIs1(String is1) {
        this.is1 = is1;
    }

    public String getIs2() {
        return is2;
    }

    public void setIs2(String is2) {
        this.is2 = is2;
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getZhengzhi() {
        return zhengzhi;
    }

    public void setZhengzhi(String zhengzhi) {
        this.zhengzhi = zhengzhi;
    }
}

有关bean
package
bean; public class School { private String id; private String plan; private String rt; private String password; private String name; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getPlan() { return plan; } public void setPlan(String plan) { this.plan = plan; } public String getRt() { return rt; } public void setRt(String rt) { this.rt = rt; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getName() { return name; } public void setName(String name) { this.name = name; } }
package bean;

public class Stu {
    private String id ;
    private String name;
    private String zhengzhi;
    private String math;
    private String english;
    private String is1;
    private String is2;
    private String is3;
    private String password;
    private String zy;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getZhengzhi() {
        return zhengzhi;
    }

    public void setZhengzhi(String zhengzhi) {
        this.zhengzhi = zhengzhi;
    }

    public String getMath() {
        return math;
    }

    public void setMath(String math) {
        this.math = math;
    }

    public String getEnglish() {
        return english;
    }

    public void setEnglish(String english) {
        this.english = english;
    }

    public String getIs1() {
        return is1;
    }

    public void setIs1(String is1) {
        this.is1 = is1;
    }

    public String getIs2() {
        return is2;
    }

    public void setIs2(String is2) {
        this.is2 = is2;
    }

    public String getIs3() {
        return is3;
    }

    public void setIs3(String is3) {
        this.is3 = is3;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getZy() {
        return zy;
    }

    public void setZy(String zy) {
        this.zy = zy;
    }
}
package bean;

public class Teacher {
    private String id;
    private String name;
    private String password;

    private String schoolid;
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getSchoolid() {
        return schoolid;
    }

    public void setSchoolid(String schoolid) {
        this.schoolid = schoolid;
    }
}

 

posted @ 2024-02-18 03:46  伐木工熊大  阅读(8)  评论(0编辑  收藏  举报