项目基础——增删改查

32 篇文章 1 订阅
15 篇文章 0 订阅

项目基础——增删改查

在这里插入图片描述

在这里插入图片描述

<%@ 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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

筱沁翼翼

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值