项目基础——增删改查

项目基础——增删改查

在这里插入图片描述

在这里插入图片描述

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>qq空间</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
  </head>
  
  <body>
  <form action="login_action.jsp">
  
 用户名<input type="text" name="username"><br>
 密           码<input type="password" name="password">
  <input type= "submit"  value="登录">
  
  </form>
  
    
    
    
    
    
  </body>
</html>

在这里插入图片描述

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="login1.User"%>
<%@page import="login1.MyJDBCUtil"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>My JSP 'index.jsp' starting page</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	</head>

	<body> 

		<%
			String msg = "";
			String username = request.getParameter("username");
			String pwd = request.getParameter("password");
			User user = MyJDBCUtil.findUserByPas(username, pwd);

			if (username.equals(user.getUserName())
					&& pwd.equals(user.getPassWord())) {

				msg = "登录成功!";
				

			} else {

				msg = "账号或密码错误!请重新输入!";

			}
		%><%=msg %>
<a href="user.jsp">用户列表</a>
	</body>
</html>


在这里插入图片描述

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="java.util.List"%>
<%@page import="login1.User"%>
<%@page import="login1.MyJDBCUtil"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
	+ request.getServerName() + ":" + request.getServerPort()
	+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>My JSP 'user.jsp' starting page</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

	</head>

	<body>
		
<table>
<caption>用户列表</caption>
<tr><th>qq</th><th>用户名</th><th>密码</th></tr>

<%
	List<User> list= MyJDBCUtil.findAllUser();
	for (int i = 0; i < list.size(); i++) {

		User user = list.get(i);
%>
				<tr><td><%=user.getQq() %></td>
				<td><%=user.getUserName() %></td>
				<td><%= user.getPassWord()%></td>
				<td>
				<a href="del_action.jsp?username=<%=list.get(i).getUserName() %>">删除 </a>
				<a href="update.jsp?username=<%=list.get(i).getUserName() %>">修改 </a>
				
				
				</tr>
				
				
				
		<%	}
		%>
</table>
	</body>
</html>

在这里插入图片描述

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="login1.MyJDBCUtil"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'action.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
  <span>当前用户:<%=request.getParameter("username")%></span>
  <form action="update_action.jsp">
  <input type="hidden" username="<%=request.getParameter("username")%>">
  <input type="text" name="password">
  <input type="submit">
  
  </form>
  
  </body>
</html>

在这里插入图片描述

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="login1.MyJDBCUtil"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'update_action.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
<%
String username=request.getParameter("username");
String password=request.getParameter("password");

MyJDBCUtil jdbcUtil=new MyJDBCUtil();
jdbcUtil.updateUser(username,password);



 %><%="更新成功!" %>



  </body>
</html>

在这里插入图片描述

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="login1.MyJDBCUtil"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'delete.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
<%
String username=request.getParameter("username");
MyJDBCUtil.deleteUser(username);
request.getRequestDispatcher("success.jsp").forward(request,response);

 %>
<%="删除成功!" %>

  </body>
</html>

在这里插入图片描述

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'success.jsp.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
  <form action="">删除成功!</form>
  </body>
</html>

在这里插入图片描述

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="login1.MyJDBCUtil"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'add.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
  <form action="add_action.jsp">
  用户名:<input type="text" name="username">
  密码:<input type="text" name="password">
  <input type="submit" value="确认添加">
  </form>


   
   
   
  </body>
</html>

在这里插入图片描述

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="login1.MyJDBCUtil"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'add.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
 
   <%
   
   String username=request.getParameter("username");
   String password=request.getParameter("password");
	MyJDBCUtil myJDBCUtil=new MyJDBCUtil();
	myJDBCUtil.addUser(username,password);

%> <%= "添加成功!"%>  
  </body>
</html>

发布了72 篇原创文章 · 获赞 10 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/BOGEWING/article/details/103119008