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>
删除给删完了,又加了一点数据。