js第八次作业

1>结合jdbc的知识实现登录
2>登录成功后转入数据展示页面
3>在展示列表中实现删除功能

login:

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <%
        request.setCharacterEncoding("UTF-8");
        Object warning =  request.getAttribute("wrong");
        if (warning != null){
            out.println(warning);
        }
    %>
    <form action="login_YN.jsp" method="post">
        用户名:<input type="text" name="user_name">
        密码<input type="password" name="password">
        <input type="submit" value="登录">
    </form>
</body>
</html>

get_Data:

<%@ page import="dao.UsersDao" %>
<%@ page import="impl.UsersDaoImpl" %>
<%@ page import="bean.User" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: HHZ
  Date: 2022/7/24
  Time: 14:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <%
        UsersDao user = new UsersDaoImpl();
        List<User> list = user.AllMessage();
    %>
    <table>
        <tr>
            <td>id</td>
            <td>用户名</td>
            <td>密码</td>

        </tr>

        <%for(User i : list){%>
        <tr>
            <td><%=i.getUser_id() %></td>
            <td><%=i.getUser_name() %></td>
            <td><%=i.getUser_pwd() %></td>
            <td><a href="delete.jsp?id='<%i.getUser_id();%>'">删除</a></td>
        </tr>
        <%} %>

    </table>
</body>
</html>

delete:

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <%
        request.setCharacterEncoding("UTF-8");
        UsersDao user = new UsersDaoImpl();
        String id = request.getParameter("id");
        System.out.println(id);
        int a = user.delete(Integer.parseInt(id));
        response.sendRedirect("get_Data.jsp");
    %>
</body>
</html>

 

 删除给删完了,又加了一点数据。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值