主頁 > 後端開發 > Java--小專案(登錄、增刪改查、分頁、搜索)

Java--小專案(登錄、增刪改查、分頁、搜索)

2020-10-04 15:39:02 後端開發

Java--小專案(登錄、增刪改查、分頁、搜索)

博客說明

文章所涉及的資料來自互聯網整理和個人總結,意在于個人學習和經驗匯總,如有什么地方侵權,請聯系本人洗掉,謝謝!

概念

技術選型

Servlet、JSP、MySQL、JDBCTempleat、Duird、BeanUtilS、tomcat

功能介紹

登錄功能,串列展示,資料添加,資料編輯,資料洗掉,批量洗掉,分頁展示,關鍵字搜索

創建JavaWeb專案

image-20200628131331797

匯入依賴

image-20200628131511018

添加頁面檔案

image-20200628132321881

資料庫

create database little; -- 創建資料庫
use little; 			   -- 使用資料庫
create table user(   -- 創建表
	id int primary key auto_increment,
	name varchar(20) not null,
	gender varchar(5),
	age int,
	address varchar(32),
	qq	varchar(20),
	email varchar(50,
	username varchar(32),
  password varchar(32),
);

串列展示

思路

首先我們需要一組串列的資料,那么我們就需要一個相對應servlet,通過我們的三層架構,使用service同一做介面,然后呼叫dao層使用JBDC操作資料庫,這樣我們可以獲得一個map集合的資料,然后就是渲染資料到jsp頁面了,通過JSTL和EL把資料回圈渲染到表里面,達到串列的展示

list.jsp
<%--
  Created by IntelliJ IDEA.
  User: tanglei
  Date: 2020/6/28
  Time: 下午2:15
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html>
<!-- 網頁使用的語言 -->
<html lang="zh-CN">
<head>
    <!-- 指定字符集 -->
    <meta charset="utf-8">
    <!-- 使用Edge最新的瀏覽器的渲染方式 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- viewport視口:網頁可以根據設定的寬度自動進行適配,在瀏覽器的內部虛擬一個容器,容器的寬度與設備的寬度相同,
    width: 默認寬度與設備的寬度相同
    initial-scale: 初始的縮放比,為1:1 -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3個meta標簽*必須*放在最前面,任何其他內容都*必須*跟隨其后! -->
    <title>用戶資訊管理系統</title>

    <!-- 1. 匯入CSS的全域樣式 -->
    <link href="https://www.cnblogs.com/guizimo/p/css/bootstrap.min.css" rel="stylesheet">
    <!-- 2. jQuery匯入,建議使用1.9以上的版本 -->
    <script src="https://www.cnblogs.com/guizimo/p/js/jquery-2.1.0.min.js"></script>
    <!-- 3. 匯入bootstrap的js檔案 -->
    <script src="https://www.cnblogs.com/guizimo/p/js/bootstrap.min.js"></script>
    <style type="text/css">
        td, th {
            text-align: center;
        }
    </style>
</head>
<body>
<div >
    <h3 style="text-align: center">用戶資訊串列</h3>
    <table border="1" >
        <tr >
            <th>編號</th>
            <th>姓名</th>
            <th>性別</th>
            <th>年齡</th>
            <th>籍貫</th>
            <th>QQ</th>
            <th>郵箱</th>
            <th>操作</th>
        </tr>
        <c:forEach items="${users}" var="user" varStatus="s">
            <tr>
                <td>${s.count}</td>
                <td>${user.name}</td>
                <td>${user.gender}</td>
                <td>${user.age}</td>
                <td>${user.address}</td>
                <td>${user.qq}</td>
                <td>${user.email}</td>
                <td><a  href="https://www.cnblogs.com/guizimo/p/update.html">修改</a>&nbsp;<a 
                                                                                        href="">洗掉</a></td>
            </tr>
        </c:forEach>

        <tr>
            <td colspan="8" align="center"><a  href="https://www.cnblogs.com/guizimo/p/add.html">添加聯系人</a></td>
        </tr>
    </table>
</div>
</body>
</html>


servlet

代碼檔案很多,就不一一展示了

image-20200628143933710

UserListServlet
package cn.guizimo.little.web.servlet;

import cn.guizimo.little.domain.User;
import cn.guizimo.little.service.UserService;
import cn.guizimo.little.service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/userListServlet")
public class UserListServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //呼叫UserService完成查詢
        UserService userService = new UserServiceImpl();
        List<User> users = userService.findAll();
        //存入request域
        req.setAttribute("users",users);
        //轉發到list.jsp
        req.getRequestDispatcher("/list.jsp").forward(req,resp);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }
}

測驗

image-20200628170505603

登錄

思路

登錄功能首先就是對表單提交的資料進行比對,驗證碼可以在生成的時候就把它存入到session中,然后在servlet中進行比對,其他的欄位在通過呼叫dao層的JDBC操作資料庫進行比對,最后把登錄成功的用戶資訊存入session中

login.jsp
<%--
  Created by IntelliJ IDEA.
  User: tanglei
  Date: 2020/6/28
  Time: 下午7:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <title>管理員登錄</title>

    <!-- 1. 匯入CSS的全域樣式 -->
    <link href="https://www.cnblogs.com/guizimo/p/css/bootstrap.min.css" rel="stylesheet">
    <!-- 2. jQuery匯入,建議使用1.9以上的版本 -->
    <script src="https://www.cnblogs.com/guizimo/p/js/jquery-2.1.0.min.js"></script>
    <!-- 3. 匯入bootstrap的js檔案 -->
    <script src="https://www.cnblogs.com/guizimo/p/js/bootstrap.min.js"></script>
    <script type="text/javascript">
        function refreshCode() {
            let vcode = document.getElementById("vcode");
            vcode.src = "https://www.cnblogs.com/guizimo/p/${pageContext.request.contextPath}/checkCodeServlet?=" + new Date().getTime();
        }
    </script>
</head>
<body>
<div  style="width: 400px;">
    <h3 style="text-align: center;">管理員登錄</h3>
    <form action="${pageContext.request.contextPath}/loginServlet" method="post">
        <div >
            <label for="user">用戶名:</label>
            <input type="text" name="username"  id="user" placeholder="請輸入用戶名"/>
        </div>

        <div >
            <label for="password">密碼:</label>
            <input type="password" name="password"  id="password" placeholder="請輸入密碼"/>
        </div>

        <div >
            <label for="vcode">驗證碼:</label>
            <input type="text" name="verifycode"  id="verifycode" placeholder="請輸入驗證碼"
                   style="width: 120px;"/>
            <a href="javascript:refreshCode()"><img src="https://www.cnblogs.com/guizimo/p/${pageContext.request.contextPath}/checkCodeServlet"
                                                    title="看不清點擊重繪" id="vcode"/></a>
        </div>
        <hr/>
        <div  style="text-align: center;">
            <input  type="submit" value="https://www.cnblogs.com/guizimo/p/登錄">
        </div>
    </form>

    <!-- 出錯顯示的資訊框 -->
    <div  role="alert">
        <button type="button"  data-dismiss="alert">
            <span>&times;</span></button>
        <strong>${login_msg}</strong>
    </div>
</div>
</body>
</html>
LoginServlet
package cn.guizimo.little.web.servlet;

import cn.guizimo.little.domain.User;
import cn.guizimo.little.service.UserService;
import cn.guizimo.little.service.impl.UserServiceImpl;
import org.apache.commons.beanutils.BeanUtils;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;

@WebServlet("/loginServlet")
public class LoginServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //設定編碼
        req.setCharacterEncoding("utf-8");
        //傳遞過來的驗證碼
        String verifycode = req.getParameter("verifycode");
        HttpSession session = req.getSession();
        //session里面的驗證碼
        String checkcode_server = (String) session.getAttribute("CHECKCODE_SERVER");
        session.removeAttribute("CHECKCODE_SERVER");
        //比對驗證碼
        if (!checkcode_server.equalsIgnoreCase(verifycode)) {
            req.setAttribute("login_msg", "驗證碼錯誤");
            req.getRequestDispatcher("/login.jsp").forward(req, resp);
            return;
        }

        Map<String, String[]> parameterMap = req.getParameterMap();
        User user = new User();
        try {
            BeanUtils.populate(user, parameterMap);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }

        UserService userService = new UserServiceImpl();
        User loginUser = userService.login(user);
        if(loginUser != null){
            session.setAttribute("user",loginUser);
            resp.sendRedirect(req.getContextPath()+"/index.jsp");
        }else {
            req.setAttribute("login_msg", "登錄失敗");
            req.getRequestDispatcher("/login.jsp").forward(req, resp);
        }


    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }
}

CheckCodeServlet
package cn.guizimo.little.web.servlet;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Random;
import javax.imageio.ImageIO;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 驗證碼
 */
@WebServlet("/checkCodeServlet")
public class CheckCodeServlet extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
		
		//服務器通知瀏覽器不要快取
		response.setHeader("pragma","no-cache");
		response.setHeader("cache-control","no-cache");
		response.setHeader("expires","0");
		
		//在記憶體中創建一個長80,寬30的圖片,默認黑色背景
		//引數一:長
		//引數二:寬
		//引數三:顏色
		int width = 80;
		int height = 30;
		BufferedImage image = new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
		
		//獲取畫筆
		Graphics g = image.getGraphics();
		//設定畫筆顏色為灰色
		g.setColor(Color.GRAY);
		//填充圖片
		g.fillRect(0,0, width,height);
		
		//產生4個隨機驗證碼,12Ey
		String checkCode = getCheckCode();
		//將驗證碼放入HttpSession中
		request.getSession().setAttribute("CHECKCODE_SERVER",checkCode);
		
		//設定畫筆顏色為黃色
		g.setColor(Color.YELLOW);
		//設定字體的小大
		g.setFont(new Font("黑體",Font.BOLD,24));
		//向圖片上寫入驗證碼
		g.drawString(checkCode,15,25);
		
		//將記憶體中的圖片輸出到瀏覽器
		//引數一:圖片物件
		//引數二:圖片的格式,如PNG,JPG,GIF
		//引數三:圖片輸出到哪里去
		ImageIO.write(image,"PNG",response.getOutputStream());
	}
	/**
	 * 產生4位隨機字串 
	 */
	private String getCheckCode() {
		String base = "0123456789ABCDEFGabcdefg";
		int size = base.length();
		Random r = new Random();
		StringBuffer sb = new StringBuffer();
		for(int i=1;i<=4;i++){
			//產生0到size-1的隨機值
			int index = r.nextInt(size);
			//在base字串中獲取下標為index的字符
			char c = base.charAt(index);
			//將c放入到StringBuffer中去
			sb.append(c);
		}
		return sb.toString();
	}
	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doGet(request,response);
	}
}

測驗

image-20200628204715757

添加人員

思路

添加操作就是把jsp提交的表單的資料向資料庫里面存盤,程序為jsp->servlet->service->dao

add.jsp
<%--
  Created by IntelliJ IDEA.
  User: tanglei
  Date: 2020/6/28
  Time: 下午8:55
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!-- HTML5檔案-->
<!DOCTYPE html>
<!-- 網頁使用的語言 -->
<html lang="zh-CN">
<head>
    <!-- 指定字符集 -->
    <meta charset="utf-8">
    <!-- 使用Edge最新的瀏覽器的渲染方式 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- viewport視口:網頁可以根據設定的寬度自動進行適配,在瀏覽器的內部虛擬一個容器,容器的寬度與設備的寬度相同,
    width: 默認寬度與設備的寬度相同
    initial-scale: 初始的縮放比,為1:1 -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3個meta標簽*必須*放在最前面,任何其他內容都*必須*跟隨其后! -->
    <title>添加用戶</title>

    <!-- 1. 匯入CSS的全域樣式 -->
    <link href="https://www.cnblogs.com/guizimo/p/css/bootstrap.min.css" rel="stylesheet">
    <!-- 2. jQuery匯入,建議使用1.9以上的版本 -->
    <script src="https://www.cnblogs.com/guizimo/p/js/jquery-2.1.0.min.js"></script>
    <!-- 3. 匯入bootstrap的js檔案 -->
    <script src="https://www.cnblogs.com/guizimo/p/js/bootstrap.min.js"></script>
</head>
<body>
<div >
    <center><h3>添加聯系人頁面</h3></center>
    <form action="${pageContext.request.contextPath}/addUserServlet" method="post">
        <div >
            <label for="name">姓名:</label>
            <input type="text"  id="name" name="name" placeholder="請輸入姓名">
        </div>

        <div >
            <label>性別:</label>
            <input type="radio" name="gender" value="https://www.cnblogs.com/guizimo/p/男" checked="checked"/>男
            <input type="radio" name="gender" value="https://www.cnblogs.com/guizimo/p/女"/>女
        </div>

        <div >
            <label for="age">年齡:</label>
            <input type="text"  id="age" name="age" placeholder="請輸入年齡">
        </div>

        <div >
            <label for="address">籍貫:</label>
            <select name="address"  id="jiguan">
                <option value="https://www.cnblogs.com/guizimo/p/廣東">廣東</option>
                <option value="https://www.cnblogs.com/guizimo/p/廣西">廣西</option>
                <option value="https://www.cnblogs.com/guizimo/p/湖南">湖南</option>
            </select>
        </div>

        <div >
            <label for="qq">QQ:</label>
            <input type="text"  name="qq" placeholder="請輸入QQ號碼"/>
        </div>

        <div >
            <label for="email">Email:</label>
            <input type="text"  name="email" placeholder="請輸入郵箱地址"/>
        </div>

        <div  style="text-align: center">
            <input  type="submit" value="https://www.cnblogs.com/guizimo/p/提交" />
            <input  type="reset" value="https://www.cnblogs.com/guizimo/p/重置" />
            <input  type="button" value="https://www.cnblogs.com/guizimo/p/回傳" />
        </div>
    </form>
</div>
</body>
</html>

AddUserServlet
package cn.guizimo.little.web.servlet;

import cn.guizimo.little.domain.User;
import cn.guizimo.little.service.UserService;
import cn.guizimo.little.service.impl.UserServiceImpl;
import org.apache.commons.beanutils.BeanUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;

@WebServlet("/addUserServlet")
public class AddUserServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        Map<String, String[]> parameterMap = req.getParameterMap();
        User user = new User();
        try {
            BeanUtils.populate(user,parameterMap);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
        UserService userService = new UserServiceImpl();
        userService.addUser(user);
        resp.sendRedirect(req.getContextPath()+"/userListServlet");
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }
}

測驗

image-20200628212933523

修改

思路

首先我們需要在打開jsp頁面的時候就查詢到這樣的一條記錄,通過這一條記錄的id作為表單的隱藏域,在servlet里面將資料進行保存即可

update.jsp
<%--
  Created by IntelliJ IDEA.
  User: tanglei
  Date: 2020/6/29
  Time: 上午10:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<!-- 網頁使用的語言 -->
<html lang="zh-CN">
<head>
    <!-- 指定字符集 -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>修改用戶</title>

    <link href="https://www.cnblogs.com/guizimo/p/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://www.cnblogs.com/guizimo/p/js/jquery-2.1.0.min.js"></script>
    <script src="https://www.cnblogs.com/guizimo/p/js/bootstrap.min.js"></script>

</head>
<body>
<div  style="width: 400px;">
    <h3 style="text-align: center;">修改聯系人</h3>
    <form action="${pageContext.request.contextPath}/updateUserServlet" method="post">
        <!--  隱藏域 提交id-->
        <input type="hidden" name="id" value="https://www.cnblogs.com/guizimo/p/${user.id}">

        <div >
            <label for="name">姓名:</label>
            <input type="text"  id="name" name="name"  value="https://www.cnblogs.com/guizimo/p/${user.name}" readonly="readonly" placeholder="請輸入姓名" />
        </div>

        <div >
            <label>性別:</label>
            <c:if test="${user.gender == '男'}">
                <input type="radio" name="gender" value="https://www.cnblogs.com/guizimo/p/男" checked />男
                <input type="radio" name="gender" value="https://www.cnblogs.com/guizimo/p/女"  />女
            </c:if>

            <c:if test="${user.gender == '女'}">
                <input type="radio" name="gender" value="https://www.cnblogs.com/guizimo/p/男"  />男
                <input type="radio" name="gender" value="https://www.cnblogs.com/guizimo/p/女" checked  />女
            </c:if>


        </div>

        <div >
            <label for="age">年齡:</label>
            <input type="text"  value="https://www.cnblogs.com/guizimo/p/${user.age}" id="age"  name="age" placeholder="請輸入年齡" />
        </div>

        <div >
            <label for="address">籍貫:</label>
            <select name="address" id="address"  >
                <c:if test="${user.address == '陜西'}">
                    <option value="https://www.cnblogs.com/guizimo/p/陜西" selected>陜西</option>
                    <option value="https://www.cnblogs.com/guizimo/p/北京">北京</option>
                    <option value="https://www.cnblogs.com/guizimo/p/上海">上海</option>
                </c:if>

                <c:if test="${user.address == '北京'}">
                    <option value="https://www.cnblogs.com/guizimo/p/陜西" >陜西</option>
                    <option value="https://www.cnblogs.com/guizimo/p/北京" selected>北京</option>
                    <option value="https://www.cnblogs.com/guizimo/p/上海">上海</option>
                </c:if>

                <c:if test="${user.address == '上海'}">
                    <option value="https://www.cnblogs.com/guizimo/p/陜西" >陜西</option>
                    <option value="https://www.cnblogs.com/guizimo/p/北京">北京</option>
                    <option value="https://www.cnblogs.com/guizimo/p/上海" selected>上海</option>
                </c:if>
            </select>
        </div>

        <div >
            <label for="qq">QQ:</label>
            <input type="text" id="qq"  value="https://www.cnblogs.com/guizimo/p/${user.qq}" name="qq" placeholder="請輸入QQ號碼"/>
        </div>

        <div >
            <label for="email">Email:</label>
            <input type="text" id="email"  value="https://www.cnblogs.com/guizimo/p/${user.email}" name="email" placeholder="請輸入郵箱地址"/>
        </div>

        <div  style="text-align: center">
            <input  type="submit" value="https://www.cnblogs.com/guizimo/p/提交" />
            <input  type="reset" value="https://www.cnblogs.com/guizimo/p/重置" />
            <a  href="https://www.cnblogs.com/guizimo/p/${pageContext.request.contextPath}/userListServlet">回傳</a>
        </div>
    </form>
</div>
</body>
</html>

FindUserServlet
package cn.guizimo.little.web.servlet;

import cn.guizimo.little.domain.User;
import cn.guizimo.little.service.UserService;
import cn.guizimo.little.service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/findUserServlet")
public class FindUserServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //1.獲取id
        String id = req.getParameter("id");
        //2.呼叫Service查詢
        UserService service = new UserServiceImpl();
        User user = service.findUserById(id);

        //3.將user存入request
        req.setAttribute("user",user);
        //4.轉發到update.jsp
        req.getRequestDispatcher("/update.jsp").forward(req,resp);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }
}

UpdateUserServlet
package cn.guizimo.little.web.servlet;

import cn.guizimo.little.domain.User;
import cn.guizimo.little.service.UserService;
import cn.guizimo.little.service.impl.UserServiceImpl;
import org.apache.commons.beanutils.BeanUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;

@WebServlet("/updateUserServlet")
public class UpdateUserServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //1.設定編碼
        req.setCharacterEncoding("utf-8");
        //2.獲取map
        Map<String, String[]> map = req.getParameterMap();
        //3.封裝物件
        User user = new User();
        try {
            BeanUtils.populate(user,map);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }

        //4.呼叫Service修改
        UserService service = new UserServiceImpl();
        service.updateUser(user);

        //5.跳轉到查詢所有Servlet
        resp.sendRedirect(req.getContextPath()+"/userListServlet");
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }
}

測驗

image-20200629111834002

洗掉

思路

通過獲取到對應的id即可到servlet中處理,操作資料庫洗掉,在進行洗掉的時候可出現提示框

DelUserServlet
package cn.guizimo.little.web.servlet;

import cn.guizimo.little.service.UserService;
import cn.guizimo.little.service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/delUserServlet")
public class DelUserServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //1.獲取id
        String id = req.getParameter("id");
        //2.呼叫service洗掉
        UserService service = new UserServiceImpl();
        service.deleteUser(id);

        //3.跳轉到查詢所有Servlet
        resp.sendRedirect(req.getContextPath()+"/userListServlet");
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }
}

測驗

image-20200629114632231

洗掉選擇的多個

思路

和洗掉差不多,最主要是獲取id的集合

DelSelectedServlet
package cn.guizimo.little.web.servlet;

import cn.guizimo.little.service.UserService;
import cn.guizimo.little.service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/delSelectedServlet")
public class DelSelectedServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //1.獲取所有id
        String[] ids = req.getParameterValues("uid");
        //2.呼叫service洗掉
        UserService service = new UserServiceImpl();
        service.delSelectedUser(ids);

        //3.跳轉查詢所有Servlet
        resp.sendRedirect(req.getContextPath()+"/userListServlet");
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }
}

測驗

image-20200629121417352

分頁

思路

在jsp中獲取查詢的總條數,每頁顯示的條數,當前的頁碼,將之傳遞給服務器,操作資料庫進行查詢

list.jsp
<%--
  Created by IntelliJ IDEA.
  User: tanglei
  Date: 2020/6/28
  Time: 下午2:15
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html>
<!-- 網頁使用的語言 -->
<html lang="zh-CN">
<head>
    <!-- 指定字符集 -->
    <meta charset="utf-8">
    <!-- 使用Edge最新的瀏覽器的渲染方式 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- viewport視口:網頁可以根據設定的寬度自動進行適配,在瀏覽器的內部虛擬一個容器,容器的寬度與設備的寬度相同,
    width: 默認寬度與設備的寬度相同
    initial-scale: 初始的縮放比,為1:1 -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3個meta標簽*必須*放在最前面,任何其他內容都*必須*跟隨其后! -->
    <title>用戶資訊管理系統</title>

    <!-- 1. 匯入CSS的全域樣式 -->
    <link href="https://www.cnblogs.com/guizimo/p/css/bootstrap.min.css" rel="stylesheet">
    <!-- 2. jQuery匯入,建議使用1.9以上的版本 -->
    <script src="https://www.cnblogs.com/guizimo/p/js/jquery-2.1.0.min.js"></script>
    <!-- 3. 匯入bootstrap的js檔案 -->
    <script src="https://www.cnblogs.com/guizimo/p/js/bootstrap.min.js"></script>
    <style type="text/css">
        td, th {
            text-align: center;
        }
    </style>
    <script>
        function deleteUser(id) {
            //用戶安全提示
            if (confirm("您確定要洗掉嗎?")) {
                //訪問路徑
                location.href = "https://www.cnblogs.com/guizimo/p/${pageContext.request.contextPath}/delUserServlet?id=" + id;
            }
        }

        window.onload = function () {
            //給洗掉選中按鈕添加單擊事件
            document.getElementById("delSelected").onclick = function () {
                if (confirm("您確定要洗掉選中條目嗎?")) {
                    var flag = false;
                    //判斷是否有選中條目
                    var cbs = document.getElementsByName("uid");
                    for (var i = 0; i < cbs.length; i++) {
                        if (cbs[i].checked) {
                            //有一個條目選中了
                            flag = true;
                            break;
                        }
                    }

                    if (flag) {//有條目被選中
                        //表單提交
                        document.getElementById("form").submit();
                    }
                }
            }
            //1.獲取第一個cb
            document.getElementById("firstCb").onclick = function () {
                //2.獲取下邊串列中所有的cb
                var cbs = document.getElementsByName("uid");
                //3.遍歷
                for (var i = 0; i < cbs.length; i++) {
                    //4.設定這些cbs[i]的checked狀態 = firstCb.checked
                    cbs[i].checked = this.checked;
                }
            }
        }
    </script>
</head>
<body>
<div >
    <h3 style="text-align: center">用戶資訊串列</h3>
    <div style="float: left;">

        <form  action="${pageContext.request.contextPath}/findUserByPageServlet" method="post">
            <div >
                <label for="exampleInputName2">姓名</label>
                <input type="text" name="name" value="https://www.cnblogs.com/guizimo/p/${condition.name[0]}"  id="exampleInputName2">
            </div>
            <div >
                <label for="exampleInputName3">籍貫</label>
                <input type="text" name="address" value="https://www.cnblogs.com/guizimo/p/${condition.address[0]}" 
                       id="exampleInputName3">
            </div>

            <div >
                <label for="exampleInputEmail2">郵箱</label>
                <input type="text" name="email" value="https://www.cnblogs.com/guizimo/p/${condition.email[0]}" 
                       id="exampleInputEmail2">
            </div>
            <button type="submit" >查詢</button>
        </form>
    </div>

    <div style="float: right;margin: 5px;">
        <a  href="https://www.cnblogs.com/guizimo/p/${pageContext.request.contextPath}/add.jsp">添加聯系人</a>
        <a  href="javascript:void(0);" id="delSelected">洗掉選中</a>
    </div>
    <form id="form" action="${pageContext.request.contextPath}/delSelectedServlet" method="post">
        <table border="1" >
            <tr >
                <th><input type="checkbox" id="firstCb"></th>
                <th>編號</th>
                <th>姓名</th>
                <th>性別</th>
                <th>年齡</th>
                <th>籍貫</th>
                <th>QQ</th>
                <th>郵箱</th>
                <th>操作</th>
            </tr>
            <c:forEach items="${pb.list}" var="user" varStatus="s">
                <tr>
                    <td><input type="checkbox" name="uid" value="https://www.cnblogs.com/guizimo/p/${user.id}"></td>
                    <td>${s.count}</td>
                    <td>${user.name}</td>
                    <td>${user.gender}</td>
                    <td>${user.age}</td>
                    <td>${user.address}</td>
                    <td>${user.qq}</td>
                    <td>${user.email}</td>
                    <td>
                        <a 
                           href="https://www.cnblogs.com/guizimo/p/${pageContext.request.contextPath}/findUserServlet?id=${user.id}">修改</a>&nbsp;
                        <a  href="javascript:deleteUser(${user.id});">洗掉</a>
                    </td>
                </tr>
            </c:forEach>
        </table>
    </form>

    <div>
        <nav aria-label="Page navigation">
            <ul >
                <c:if test="${pb.currentPage == 1}">
                    <li >
                        <a href="https://www.cnblogs.com/guizimo/p/${pageContext.request.contextPath}/findUserByPageServlet?currentPage=1&rows=5&name=${condition.name[0]}&address=${condition.address[0]}&email=${condition.email[0]}"
                           aria-label="Previous">
                            <span aria-hidden="true">&laquo;</span>
                        </a>
                    </li>
                </c:if>
                <c:if test="${pb.currentPage != 1}">
                    <li>
                        <a href="https://www.cnblogs.com/guizimo/p/${pageContext.request.contextPath}/findUserByPageServlet?currentPage=${pb.currentPage - 1}&rows=5&name=${condition.name[0]}&address=${condition.address[0]}&email=${condition.email[0]}"
                           aria-label="Previous">
                            <span aria-hidden="true">&laquo;</span>
                        </a>
                    </li>
                </c:if>

                <c:forEach begin="1" end="${pb.totalPage}" var="i">
                    <c:if test="${pb.currentPage == i}">
                        <li ><a
                                href="https://www.cnblogs.com/guizimo/p/${pageContext.request.contextPath}/findUserByPageServlet?currentPage=${i}&rows=5&name=${condition.name[0]}&address=${condition.address[0]}&email=${condition.email[0]}">${i}</a>
                        </li>
                    </c:if>
                    <c:if test="${pb.currentPage != i}">
                        <li>
                            <a href="https://www.cnblogs.com/guizimo/p/${pageContext.request.contextPath}/findUserByPageServlet?currentPage=${i}&rows=5&name=${condition.name[0]}&address=${condition.address[0]}&email=${condition.email[0]}">${i}</a>
                        </li>
                    </c:if>
                </c:forEach>
                <c:if test="${pb.currentPage == pb.totalPage}">
                    <li >
                        <a href="https://www.cnblogs.com/guizimo/p/${pageContext.request.contextPath}/findUserByPageServlet?currentPage=${pb.totalPage}&rows=5&name=${condition.name[0]}&address=${condition.address[0]}&email=${condition.email[0]}"
                           aria-label="Next">
                            <span aria-hidden="true">&raquo;</span>
                        </a>
                    </li>
                </c:if>
                <c:if test="${pb.currentPage != pb.totalPage}">
                    <li>
                        <a href="https://www.cnblogs.com/guizimo/p/${pageContext.request.contextPath}/findUserByPageServlet?currentPage=${pb.currentPage + 1}&rows=5&name=${condition.name[0]}&address=${condition.address[0]}&email=${condition.email[0]}"
                           aria-label="Next">
                            <span aria-hidden="true">&raquo;</span>
                        </a>
                    </li>
                </c:if>

                <span style="font-size: 25px;margin-left: 5px;">
                    共${pb.totalCount}條記錄,共${pb.totalPage}頁
                </span>
            </ul>
        </nav>
    </div>

</div>
</body>
</html>


FindUserByPageServlet
package cn.guizimo.little.web.servlet;


import cn.guizimo.little.domain.PageBean;
import cn.guizimo.little.domain.User;
import cn.guizimo.little.service.UserService;
import cn.guizimo.little.service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;

@WebServlet("/findUserByPageServlet")
public class FindUserByPageServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");

        //1.獲取引數
        String currentPage = request.getParameter("currentPage");//當前頁碼
        String rows = request.getParameter("rows");//每頁顯示條數

        if(currentPage == null || "".equals(currentPage)){
            currentPage = "1";
        }

        if(rows == null || "".equals(rows)){
            rows = "5";
        }
        
        //獲取條件查詢引數
        Map<String, String[]> condition = request.getParameterMap();

        //2.呼叫service查詢
        UserService service = new UserServiceImpl();
        PageBean<User> pb = service.findUserByPage(currentPage,rows,condition);

        System.out.println(pb);

        //3.將PageBean存入request
        request.setAttribute("pb",pb);
        request.setAttribute("condition",condition);//將查詢條件存入request
        //4.轉發到list.jsp
        request.getRequestDispatcher("/list.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}

測驗

image-20200629190257416

條件查詢

思路

主要是在sql陳述句的撰寫

jsp
<div style="float: left;">
        <form  action="${pageContext.request.contextPath}/findUserByPageServlet" method="post">
            <div >
                <label for="exampleInputName2">姓名</label>
                <input type="text" name="name" value="https://www.cnblogs.com/guizimo/p/${condition.name[0]}"  id="exampleInputName2">
            </div>
            <div >
                <label for="exampleInputName3">籍貫</label>
                <input type="text" name="address" value="https://www.cnblogs.com/guizimo/p/${condition.address[0]}" 
                       id="exampleInputName3">
            </div>
            <div >
                <label for="exampleInputEmail2">郵箱</label>
                <input type="text" name="email" value="https://www.cnblogs.com/guizimo/p/${condition.email[0]}" 
                       id="exampleInputEmail2">
            </div>
            <button type="submit" >查詢</button>
        </form>
    </div>
dao層方法
@Override
    public int findTotalCount(Map<String, String[]> condition) {
        //1.定義模板初始化sql
        String sql = "select count(*) from user where 1 = 1 ";
        StringBuilder sb = new StringBuilder(sql);
        //2.遍歷map
        Set<String> keySet = condition.keySet();
        //定義引數的集合
        List<Object> params = new ArrayList<Object>();
        for (String key : keySet) {
            //排除分頁條件引數
            if("currentPage".equals(key) || "rows".equals(key)){
                continue;
            }
            //獲取value
            String value = https://www.cnblogs.com/guizimo/p/condition.get(key)[0];
            //判斷value是否有值
            if(value != null && !"".equals(value)){
                //有值
                sb.append(" and "+key+" like ? ");
                params.add("%"+value+"%");//?條件的值
            }
        }
        System.out.println(sb.toString());
        System.out.println(params);
        return template.queryForObject(sb.toString(),Integer.class,params.toArray());
    }

    @Override
    public List<User> findByPage(int start, int rows, Map<String, String[]> condition) {
        String sql = "select * from user  where 1 = 1 ";
        StringBuilder sb = new StringBuilder(sql);
        //2.遍歷map
        Set<String> keySet = condition.keySet();
        //定義引數的集合
        List<Object> params = new ArrayList<Object>();
        for (String key : keySet) {
            //排除分頁條件引數
            if("currentPage".equals(key) || "rows".equals(key)){
                continue;
            }
            //獲取value
            String value = https://www.cnblogs.com/guizimo/p/condition.get(key)[0];
            //判斷value是否有值
            if(value != null && !"".equals(value)){
                //有值
                sb.append(" and "+key+" like ? ");
                params.add("%"+value+"%");//?條件的值
            }
        }
        //添加分頁查詢
        sb.append(" limit ?,? ");
        //添加分頁查詢引數值
        params.add(start);
        params.add(rows);
        sql = sb.toString();
        System.out.println(sql);
        System.out.println(params);
        return template.query(sql,new BeanPropertyRowMapper<User>(User.class),params.toArray());
    }
測驗

image-20200629191252508

感謝

黑馬程式員

萬能的網路

以及勤勞的自己

關注公眾號: 歸子莫,獲取更多的資料,還有更長的學習計劃

轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/154803.html

標籤:Java

上一篇:Object的記憶體布局

下一篇:offer到手!美團Java崗四面(多執行緒+redis+JVM+資料庫)

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • 【C++】Microsoft C++、C 和匯編程式檔案

    ......

    uj5u.com 2020-09-10 00:57:23 more
  • 例外宣告

    相比于斷言適用于排除邏輯上不可能存在的狀態,例外通常是用于邏輯上可能發生的錯誤。 例外宣告 Item 1:當函式不可能拋出例外或不能接受拋出例外時,使用noexcept 理由 如果不打算拋出例外的話,程式就會認為無法處理這種錯誤,并且應當盡早終止,如此可以有效地阻止例外的傳播與擴散。 示例 //不可 ......

    uj5u.com 2020-09-10 00:57:27 more
  • Codeforces 1400E Clear the Multiset(貪心 + 分治)

    鏈接:https://codeforces.com/problemset/problem/1400/E 來源:Codeforces 思路:給你一個陣列,現在你可以進行兩種操作,操作1:將一段沒有 0 的區間進行減一的操作,操作2:將 i 位置上的元素歸零。最終問:將這個陣列的全部元素歸零后操作的最少 ......

    uj5u.com 2020-09-10 00:57:30 more
  • UVA11610 【Reverse Prime】

    本人看到此題沒有翻譯,就附帶了一個自己的翻譯版本 思考 這一題,它的第一個要求是找出所有 $7$ 位反向質數及其質因數的個數。 我們應該需要質數篩篩選1~$10^{7}$的所有數,這里就不慢慢介紹了。但是,重讀題,我們突然發現反向質數都是 $7$ 位,而將它反過來后的數字卻是 $6$ 位數,這就說明 ......

    uj5u.com 2020-09-10 00:57:36 more
  • 統計區間素數數量

    1 #pragma GCC optimize(2) 2 #include <bits/stdc++.h> 3 using namespace std; 4 bool isprime[1000000010]; 5 vector<int> prime; 6 inline int getlist(int ......

    uj5u.com 2020-09-10 00:57:47 more
  • C/C++編程筆記:C++中的 const 變數詳解,教你正確認識const用法

    1、C中的const 1、區域const變數存放在堆疊區中,會分配記憶體(也就是說可以通過地址間接修改變數的值)。測驗代碼如下: 運行結果: 2、全域const變數存放在只讀資料段(不能通過地址修改,會發生寫入錯誤), 默認為外部聯編,可以給其他源檔案使用(需要用extern關鍵字修飾) 運行結果: ......

    uj5u.com 2020-09-10 00:58:04 more
  • 【C++犯錯記錄】VS2019 MFC添加資源不懂如何修改資源宏ID

    1. 首先在資源視圖中,添加資源 2. 點擊新添加的資源,復制自動生成的ID 3. 在解決方案資源管理器中找到Resource.h檔案,編輯,使用整個專案搜索和替換的方式快速替換 宏宣告 4. Ctrl+Shift+F 全域搜索,點擊查找全部,然后逐個替換 5. 為什么使用搜索替換而不使用屬性視窗直 ......

    uj5u.com 2020-09-10 00:59:11 more
  • 【C++犯錯記錄】VS2019 MFC不懂的批量添加資源

    1. 打開資源頭檔案Resource.h,在其中預先定義好宏 ID(不清楚其實ID值應該設定多少,可以先新建一個相同的資源項,再在這個資源的ID值的基礎上遞增即可) 2. 在資源視圖中選中專案資源,按F7編輯資源檔案,按 ID 型別 相對路徑的形式添加 資源。(別忘了先把檔案拷貝到專案中的res檔案 ......

    uj5u.com 2020-09-10 01:00:19 more
  • C/C++編程筆記:關于C++的參考型別,專供新手入門使用

    今天要講的是C++中我最喜歡的一個用法——參考,也叫別名。 參考就是給一個變數名取一個變數名,方便我們間接地使用這個變數。我們可以給一個變數創建N個參考,這N + 1個變數共享了同一塊記憶體區域。(參考型別的變數會占用記憶體空間,占用的記憶體空間的大小和指標型別的大小是相同的。雖然參考是一個物件的別名,但 ......

    uj5u.com 2020-09-10 01:00:22 more
  • 【C/C++編程筆記】從頭開始學習C ++:初學者完整指南

    眾所周知,C ++的學習曲線陡峭,但是花時間學習這種語言將為您的職業帶來奇跡,并使您與其他開發人員區分開。您會更輕松地學習新語言,形成真正的解決問題的技能,并在編程的基礎上打下堅實的基礎。 C ++將幫助您養成良好的編程習慣(即清晰一致的編碼風格,在撰寫代碼時注釋代碼,并限制類內部的可見性),并且由 ......

    uj5u.com 2020-09-10 01:00:41 more
最新发布
  • Rust中的智能指標:Box<T> Rc<T> Arc<T> Cell<T> RefCell<T> Weak

    Rust中的智能指標是什么 智能指標(smart pointers)是一類資料結構,是擁有資料所有權和額外功能的指標。是指標的進一步發展 指標(pointer)是一個包含記憶體地址的變數的通用概念。這個地址參考,或 ” 指向”(points at)一些其 他資料 。參考以 & 符號為標志并借用了他們所 ......

    uj5u.com 2023-04-20 07:24:10 more
  • Java的值傳遞和參考傳遞

    值傳遞不會改變本身,參考傳遞(如果傳遞的值需要實體化到堆里)如果發生修改了會改變本身。 1.基本資料型別都是值傳遞 package com.example.basic; public class Test { public static void main(String[] args) { int ......

    uj5u.com 2023-04-20 07:24:04 more
  • [2]SpinalHDL教程——Scala簡單入門

    第一個 Scala 程式 shell里面輸入 $ scala scala> 1 + 1 res0: Int = 2 scala> println("Hello World!") Hello World! 檔案形式 object HelloWorld { /* 這是我的第一個 Scala 程式 * 以 ......

    uj5u.com 2023-04-20 07:23:58 more
  • 理解函式指標和回呼函式

    理解 函式指標 指向函式的指標。比如: 理解函式指標的偽代碼 void (*p)(int type, char *data); // 定義一個函式指標p void func(int type, char *data); // 宣告一個函式func p = func; // 將指標p指向函式func ......

    uj5u.com 2023-04-20 07:23:52 more
  • Django筆記二十五之資料庫函式之日期函式

    本文首發于公眾號:Hunter后端 原文鏈接:Django筆記二十五之資料庫函式之日期函式 日期函式主要介紹兩個大類,Extract() 和 Trunc() Extract() 函式作用是提取日期,比如我們可以提取一個日期欄位的年份,月份,日等資料 Trunc() 的作用則是截取,比如 2022-0 ......

    uj5u.com 2023-04-20 07:23:45 more
  • 一天吃透JVM面試八股文

    什么是JVM? JVM,全稱Java Virtual Machine(Java虛擬機),是通過在實際的計算機上仿真模擬各種計算機功能來實作的。由一套位元組碼指令集、一組暫存器、一個堆疊、一個垃圾回收堆和一個存盤方法域等組成。JVM屏蔽了與作業系統平臺相關的資訊,使得Java程式只需要生成在Java虛擬機 ......

    uj5u.com 2023-04-20 07:23:31 more
  • 使用Java接入小程式訂閱訊息!

    更新完微信服務號的模板訊息之后,我又趕緊把微信小程式的訂閱訊息給實作了!之前我一直以為微信小程式也是要企業才能申請,沒想到小程式個人就能申請。 訊息推送平臺🔥推送下發【郵件】【短信】【微信服務號】【微信小程式】【企業微信】【釘釘】等訊息型別。 https://gitee.com/zhongfuch ......

    uj5u.com 2023-04-20 07:22:59 more
  • java -- 緩沖流、轉換流、序列化流

    緩沖流 緩沖流, 也叫高效流, 按照資料型別分類: 位元組緩沖流:BufferedInputStream,BufferedOutputStream 字符緩沖流:BufferedReader,BufferedWriter 緩沖流的基本原理,是在創建流物件時,會創建一個內置的默認大小的緩沖區陣列,通過緩沖 ......

    uj5u.com 2023-04-20 07:22:49 more
  • Java-SpringBoot-Range請求頭設定實作視頻分段傳輸

    老實說,人太懶了,現在基本都不喜歡寫筆記了,但是網上有關Range請求頭的文章都太水了 下面是抄的一段StackOverflow的代碼...自己大修改過的,寫的注釋挺全的,應該直接看得懂,就不解釋了 寫的不好...只是希望能給視頻網站開發的新手一點點幫助吧. 業務場景:視頻分段傳輸、視頻多段傳輸(理 ......

    uj5u.com 2023-04-20 07:22:42 more
  • Windows 10開發教程_編程入門自學教程_菜鳥教程-免費教程分享

    教程簡介 Windows 10開發入門教程 - 從簡單的步驟了解Windows 10開發,從基本到高級概念,包括簡介,UWP,第一個應用程式,商店,XAML控制元件,資料系結,XAML性能,自適應設計,自適應UI,自適應代碼,檔案管理,SQLite資料庫,應用程式到應用程式通信,應用程式本地化,應用程式 ......

    uj5u.com 2023-04-20 07:22:35 more