Day5

今日继续进行了之前的任务编写。

mainPage

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>主界面</title>
    <style>
        #head_{
            height: 100px;
            width: 100%;
            background-color: slategray;
        }
        #personFile{
            width: 120px;
            height: 50px;
            padding-top: 25px;
            margin-left: 90%;
        }
        #search{
            height: 70px;
            width: 100%;
            background-color: cornflowerblue;
        }
        #inner_s{
            /*width: 200px;
            height: 40px;
            padding-right: 70%;
            padding-top: 50%;*/
            width: 30%;
            padding-top:25px;
            padding-left: 45%;
        }
        #table{
            margin-left: 30%;
            margin-top: 30px;
        }
        td{
            text-align: center;
            height: 20px;
            width: 150px;
            border: black 1px solid;
            padding:1px;

        }

    </style>


</head>
<body>

<div id="head_">
    <div id="personFile">
        名字:<span style="color: red">${user.getU_name()}</span><br>
        编号:<span style="color: red">${user.getU_id()}</span>
    </div>
</div>


<div id="search">
    <div id="inner_s">
        <input type="text" style="font-size: 20px; height: 26px;width: 190px">&nbsp;&nbsp;
        <button  style="font-size: 18px; height: 28px;">查询</button>
    </div>
</div>

<div>
    <table id="table" style="height: 30px;width: 700px;border: black 1px solid;border-collapse:collapse;">
        <tr >
            <td>学生id</td>
            <td>学生名字</td>
            <td>学生电话</td>
            <td>查看成绩</td>
            <td>操作</td>
        </tr>
        <tr>
            <td>1001</td>
            <td>赵括</td>
            <td>125421554</td>
            <td><button style="color: chocolate">查看成绩</button></td>
            <td><button style="color: chocolate">修改</button>
                <button style="color: chocolate">删除</button>
            </td>
        </tr>
        <tr>
            <td>1001</td>
            <td>赵括</td>
            <td>125421554</td>
            <td><button style="color: chocolate">查看成绩</button></td>
            <td><button style="color: chocolate">修改</button>
                <button style="color: chocolate">删除</button>
            </td>
        </tr>
        <tr>
            <td>1001</td>
            <td>赵括</td>
            <td>125421554</td>
            <td><button style="color: chocolate">查看成绩</button></td>
            <td><button style="color: chocolate">修改</button>
                <button style="color: chocolate">删除</button>
            </td>
        </tr>
        <tr>
            <td>1001</td>
            <td>赵括</td>
            <td>125421554</td>
            <td><button style="color: chocolate">查看成绩</button></td>
            <td><button style="color: chocolate">修改</button>
                <button style="color: chocolate">删除</button>
            </td>
        </tr>
    </table>
</div>


<div>







</div>




</body>
</html>

util

ConnectionFactory

public class ConnectionFactory {
    private static DataSource dataSource = new ComboPooledDataSourse();

    public static Connection getConnection(){
        try {
            return dataSource.getConnection();
        }catch (SQLException e){
            e.printStackTrace();
        }
        return null;
    }

    public static void close(Connection connection, PreparedStatement preparedStatement, ResultSet resultSet){
        try {
            if (resultSet != null){resultSet.close();}
            if (preparedStatement != null){preparedStatement.close();}
            if (connection != null){connection.close();}
        }catch (SQLException e){
            e.printStackTrace();
        }
    }
}

test

public class Test {
    public static void main(String[] args) {
        int id = 1001;
        String pwd = "a1";
        User u = new User();
        u.setU_id(id);
        u.setU_pwd(pwd);

        LoginDaoImpl l = new LoginDaoImpl();
        User retUse = l.logindao(u);
        if (retUse != null){
            System.out.println(retUse.toString());
            System.out.println("账户和密码一致");
        }else {
            System.out.println("账户和密码不一致");
        }
    }
}

 

posted @ 2022-01-04 20:03  灰幕  阅读(27)  评论(0)    收藏  举报