每日总结5

今日时间安排满满,整整上了一天的课,认真学了了一整天,  基本都是考研的科目,课程非常重要,同时,学习的结果收获满满,今日课程有,早上八点的计算机网络课,课程上进行了一次课程小测,做的还不错,然后进行了概率论的学习,下午是英语口语,然后是 web应用技术与开发,晚上吃晚饭后研究了一段时间的增删改查。

 

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"

    pageEncoding="ISO-8859-1"%>

<!DOCTYPE html>

<html>

<head>

    <meta charset="UTF-8">

    <title>用户管理系统</title>

</head>

<body>

    <h1>用户管理系统</h1>

    <form method="post" action="UserServlet">

        <label>姓名:</label><input type="text" name="name"><br>

        <label>年龄:</label><input type="text" name="age"><br>

        <button type="submit">添加用户</button>

    </form>

    <hr>

    <table>

        <tr>

            <th>ID</th>

            <th>姓名</th>

            <th>年龄</th>

            <th>操作</th>

        </tr>

        <%-- 查询用户 --%>

        <%

            String url = "http://localhost:8080/JavaWebDemo/UserServlet";

            URL obj = new URL(url);

            HttpURLConnection con = (HttpURLConnection) obj.openConnection();

            con.setRequestMethod("GET");

            BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));

            String inputLine;

            StringBuilder response = new StringBuilder();

            while ((inputLine = in.readLine()) != null) {

                response.append(inputLine);

            }

            in.close();

            out.println(response.toString());

        %>

        <%-- 删除用户 --%>

        <script>

            function deleteUser(id) {

                if (confirm("确定要删除该用户吗?")) {

                    var xhr = new XMLHttpRequest();

                    xhr.open("DELETE", "UserServlet?id=" + id, true);

                    xhr.onreadystatechange = function() {

                        if (xhr.readyState == 4 && xhr.status == 200) {

                            alert(xhr.responseText);

                            location.reload();

                        }

                    };

                    xhr.send();

                }

            }

        </script>

    </table>

</body>

</html>

posted @ 2023-09-16 21:39  冉子旭  阅读(16)  评论(0)    收藏  举报