項目基礎——增刪改查

項目基礎——增刪改查

在這裏插入圖片描述

在這裏插入圖片描述

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章