当前位置: 首页 > news >正文

Web-7-深入理解Cookie与Session:实现用户跟踪和数据存储

深入理解Cookie与Session:实现用户跟踪和数据存储

今日目标

1.掌握客户端会话跟踪技术Cookie

2.掌握服务端会话跟踪技术Sesssion

1.会话跟踪技术介绍

会话:用户打开浏览器,访问web服务器的资源,会话建立,直到有一方断开连接,会话结束。一次会话中可以包含多次请求和响应.

HTTP协议是无状态协议,每次同一浏览器向服务器请求时,服务器都会将该请求视为新的请求,因此我们需要会话跟踪技术来实现同一会话内数据共享

思考:下图建立几个会话?

每个浏览器都会与服务端建立了一个会话,加起来总共是3个会话。

思考:服务器如何识别多次请求是否来自于同一浏览器?
这就需要我们学习今天的内容,会话跟踪技术。

会话跟踪:一种维护浏览器状态的方法,服务器需要识别多次请求是否来自于同一浏览器,以便在同一次会话的多次请求间共享数据

原因:HTTP协议是无状态的,每次浏览器向服务器请求时,服务器都会将该请求视为新的请求,因此我们需要会话跟踪技术来实现会话内数据共享

思考:一个会话中的多次请求为什么要共享数据呢?有了这个数据共享功能后能实现哪些功能呢?

购物车功能: 加入购物车去购物车结算是两次请求,但是后面这次请求要想展示前一次请求所添加的商品,就需要用到数据共享。

记住我功能:当用户登录成功后,勾选记住我按钮后下次再登录的时候,网站就会自动填充用户名和密码,简化用户的登录操作,多次登录就会有多次请求,他们之间也涉及到共享数据

实现方式

  • 客户端会话跟踪技术:Cookie

  • 服务端会话跟踪技术:Session

2.Cookie基本使用

Cookie:客户端会话跟踪技术,将数据保存到客户端,以后每次请求都携带Cookie数据进行访问

2.1基本使用

2.1.1 发送Cookie

  • 创建Cookie对象,设置数据

Cookie cookie = new Cookie("key","value");
  • 发送Cookie到客户端:使用response对象

response.addCookie(cookie);

2.1.2获取Cookie

  • 获取客户端携带的所有Cookie,使用request对象

Cookie[] cookies = request.getCookies();
  • 遍历数组,获取每一个Cookie对象:for

  • 使用Cookie对象方法获取数据

cookie.getName();
cookie.getValue();

2.2代码实现

  • 创建08_Cookie_Session的Maven Web项目,并添加Servlet依赖在Pom.xml中

  <dependencies><dependency><groupId>javax.servlet</groupId><artifactId>javax.servlet-api</artifactId><version>4.0.1</version><scope>provided</scope></dependency></dependencies>
Cookie[] cookies = request.getCookies();
  • 创建AServlet用于发送Cookie到浏览器

package com.zbbmeta.cookie;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
/*** 发送Cookie*/
@WebServlet(value = "/a")
public class Aservlet extends HttpServlet {@Overrideprotected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {//get请求//1.创建cookie对象Cookie cookie = new Cookie("name","lisi");//2.发送cookie对象到浏览器response.addCookie(cookie);}@Overrideprotected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {//post请求doGet(request, response);}
}
  • 创建BServlet用于获取Cookie数据

package com.zbbmeta.cookie;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;/*** 获取Cookie*/
@WebServlet(value = "/b")
public class Bservlet extends HttpServlet {@Overrideprotected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {//get请求//3.获取客户端携带的所有Cookie,使用request对象Cookie[] cookies = request.getCookies();response.setContentType("text/html;charset=utf-8");PrintWriter writer = response.getWriter();if(cookies!=null){//4.遍历数组,获取每一个Cookie对象:forfor (Cookie cookie : cookies) {//5.使用Cookie对象方法获取数据String name = cookie.getName();String value = cookie.getValue();writer.write(name+" = "+value+"<br>");}}else {writer.write("cookie不存在<br>");}}@Overrideprotected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {//post请求doGet(request, response);}
}
  • 在浏览器中先访问地址:http://localhost:8080/cookie-session/a,然后在访问http://localhost:8080/cookie-session/b查看浏览器结果,如图所示:

3Cookie原理

Cookie的实现是基于HTTP协议的

  • 响应头:set-cookie

  • 请求头:cookie

在浏览器 查看Cookie

3.Cookie使用细节

3.1Cookie 存活时间

  • 默认情况下,Cookie 存储在浏览器内存中,当浏览器关闭,内存释放,则Cookie被销毁

  • setMaxAge(int seconds):设置Cookie存活时间,但是是秒
    • 负数:默认值,Cookie在当前浏览器内存中,当浏览器关闭,则 Cookie被销毁

    • 正数:将 Cookie写入浏览器所在电脑的硬盘,持久化存储。到时间自动删除

  • 零:立即过期,步骤和结果和正数步骤一致,这里就不掩饰了 完整代码:

  • AServlet

package com.zbbmeta.cookie;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
/*** 发送Cookie*/
@WebServlet(value = "/a")
public class Aservlet extends HttpServlet {@Overrideprotected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {//get请求//1.创建cookie对象Cookie cookie = new Cookie("name","lisi");//3. setMaxAge(int seconds):设置Cookie存活时间,但是是秒cookie.setMaxAge(10);
//        cookie.setMaxAge(-1);//cookie.setMaxAge(0);//2.发送cookie对象到浏览器response.addCookie(cookie);}@Overrideprotected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {//post请求doGet(request, response);}
}

3.2Cookie 存储问题

  • 如需要存储空格,则需要进行转码:URL编码
    • 会出现问题

  • 解决方法

  1. 在发送cookie端进行URL编码

URLEncoder.encode(name,"UTF-8");
  1. 在获取cookie端进行URL解码

value = URLDecoder.decode(name,"UTF-8");
  1. 浏览器显示结果

  • 完整代码

  • AServlet

package com.zbbmeta.cookie;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.net.URLDecoder;
import java.net.URLEncoder;/*** 发送Cookie*/
@WebServlet(value = "/a")
public class Aservlet extends HttpServlet {@Overrideprotected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {//get请求//1.创建cookie对象String name = " lisi";name = URLEncoder.encode(name,"UTF-8");Cookie cookie = new Cookie("name",name);//3. setMaxAge(int seconds):设置Cookie存活时间,但是是秒cookie.setMaxAge(10);
//        cookie.setMaxAge(-1);//cookie.setMaxAge(0);//2.发送cookie对象到浏览器response.addCookie(cookie);}@Overrideprotected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {//post请求doGet(request, response);}
}
  • BServlet

package com.zbbmeta.cookie;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.URLDecoder;/*** 获取Cookie*/
@WebServlet(value = "/b")
public class Bservlet extends HttpServlet {@Overrideprotected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {//get请求//3.获取客户端携带的所有Cookie,使用request对象Cookie[] cookies = request.getCookies();response.setContentType("text/html;charset=utf-8");PrintWriter writer = response.getWriter();if(cookies!=null){//4.遍历数组,获取每一个Cookie对象:forfor (Cookie cookie : cookies) {//5.使用Cookie对象方法获取数据String name = cookie.getName();String value = cookie.getValue();value = URLDecoder.decode(value,"UTF-8");writer.write(name+" = |"+value+"<br>");}}else {writer.write("cookie不存在<br>");}}@Overrideprotected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {//post请求doGet(request, response);}
}
  • Tomcat7 Cookie 不能直接存储中文,Tomcat8 Cookie可以存储中文,但不能存储空格

4.Session基本使用

Session:服务端会话跟踪技术:将数据保存到服务端

4.1基本使用

4.1.1 获取Session

  • JavaEE 提供 HttpSession接口,来实现一次会话的多次请求间数据共享功能

  • 使用:

    • 获取Session对象

HttpSession session = request.getSession();

4.1.2 Session对象功能

  • Session对象功能:

   void setAttribute(String name, Object o)//存储数据到 session 域中Object getAttribute(String name) //根据 key,获取值void removeAttribute(String name) //根据 key,删除该键值对

4.2代码实现

  • 创建CServlet用于存储数据到Session对象

package com.zbbmeta.session;import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;/*** 1.存储Session数据到服务器*/
@WebServlet(value = "/c")
public class CServlet extends HttpServlet {@Overrideprotected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {//get请求//1.获取Session对象HttpSession session = request.getSession();//2.存储数据到sessionsession.setAttribute("name","session_wangwu");response.setContentType("text/html;charset=utf-8");PrintWriter writer = response.getWriter();writer.write("访问了C资源"+"<br>");}@Overrideprotected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {//post请求doGet(request, response);}
}
  • 创建DServlet用于从Session对象获取数据

package com.zbbmeta.session;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.io.PrintWriter;/*** 2.在Session对象中获取数据*/
@WebServlet(value = "/d")
public class DServlet extends HttpServlet {@Overrideprotected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {//get请求//1.获取Session对象HttpSession session = request.getSession();//2.存储数据到sessionObject name = session.getAttribute("name");response.setContentType("text/html;charset=utf-8");PrintWriter writer = response.getWriter();writer.write("访问了D资源"+"<br>");if(name!=null){writer.write(name.toString()+"<br>");}else {writer.write("Session数据不存在"+"<br>");}}@Overrideprotected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {//post请求doGet(request, response);}
}
  • 在浏览器中先访问地址:http://localhost:8080/cookie-session/c,然后在访问http://localhost:8080/cookie-session/d查看浏览器结果,如图所示:

5.Session原理

Session基于Cookie实现

思考:如果新开一个浏览器,还是同一个session对象么?

答案:上图显示的获取的Session对象不是一个,每一个浏览器都会获取一个新的Session对象

  • 判断Session对象是否是新对象代码
    • CServlet

package com.zbbmeta.session;import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;/*** 1.存储Session数据到服务器*/
@WebServlet(value = "/c")
public class CServlet extends HttpServlet {@Overrideprotected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {//get请求response.setContentType("text/html;charset=utf-8");PrintWriter writer = response.getWriter();//1.获取Session对象HttpSession session = request.getSession();//3.判断Session是否是新对象boolean aNew = session.isNew();//4.获取SessionIDString id = session.getId();writer.write("session 是新的= "+aNew+" session id : "+id+"<br>");//2.存储数据到sessionsession.setAttribute("name","session_wangwu");writer.write("访问了C资源"+"<br>");}@Overrideprotected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {//post请求doGet(request, response);}
}
  • DServlet

package com.zbbmeta.session;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.io.PrintWriter;/*** 2.在Session对象中获取数据*/
@WebServlet(value = "/d")
public class DServlet extends HttpServlet {@Overrideprotected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {//get请求response.setContentType("text/html;charset=utf-8");PrintWriter writer = response.getWriter();//1.获取Session对象HttpSession session = request.getSession();//3.判断Session是否是新对象boolean aNew = session.isNew();//4.获取SessionIDString id = session.getId();writer.write("session 是新的= "+aNew+" session id : "+id+"<br>");//2.存储数据到sessionObject name = session.getAttribute("name");writer.write("访问了D资源"+"<br>");if(name!=null){writer.write(name.toString()+"<br>");}else {writer.write("Session数据不存在"+"<br>");}}@Overrideprotected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {//post请求doGet(request, response);}
}
  • 浏览器结果

6.Session使用细节

6.1.Session 钝化、活化

  • Session 钝化、活化:
    • 服务器重启后,Session中的数据是否还在?
      • 钝化:在服务器正常关闭后, Tomcat自动将 Session数据写入硬盘的文件中

      • 活化:再次启动服务器后,从文件中加载数据到Session中

在IDEA中配置钝化

查看钝化数据

查看钝化数据的前台条件是,我们已经有Session对象存储数据

  • 1.我们现在的08_Cookie_Session项目启动的,并且访问了c资源

  • 2.关闭项目

  • 3.根据路径查看session数据

  • 4.发现有后缀为.ser的文件

  • 5.重新启动.ser文件就不存在了(步骤五就是活化)

6.2.Seesion 销毁

6.2.1 默认情况下,无操作,30分钟自动销毁

  • 获取存活时间方式

        //5.获取存活时间int maxInactiveInterval = session.getMaxInactiveInterval();
  • 访问c,浏览器结果

  • 停留10s,访问d,浏览器结果

思考:为什么停留10s后,session对象的存活时间还是1800s?

存活时间表示的是没有访问资源的情况下,如果访问了,则存活时间重新变为1800s.

6.2.2 web.xml配置存活时间

可以通过web.xml进行配置,单位为分钟

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"version="4.0"><session-config>
<!--  单位是分钟--><session-timeout>2</session-timeout></session-config>
</web-app>

  • 调用 Session对象的 invalidate()方法

注意:最好关闭浏览器再打开

6.1Cookie和Session的对比

  • 相同点
    • Cookie 和 Session 都是来完成一次会话内多次请求间数据共享的

  • 区别
    • 键值对数量:Cookie 存一个键和一个值,Session 存n个键和值

    • 存储位置:Cookie 是将数据存储在客户端,Session 将数据存储在服务端

    • 安全性:Cookie 不安全,Session 安全

    • 数据大小:Cookie 最大4KB,Session 无大小限制

    • 存储时间:Cookie默认浏览器关闭,Session 默认30分钟

    • 服务器性能:Cookie 不占服务器资源,Session 占用服务器资源

相关文章:

Web-7-深入理解Cookie与Session:实现用户跟踪和数据存储

深入理解Cookie与Session&#xff1a;实现用户跟踪和数据存储 今日目标 1.掌握客户端会话跟踪技术Cookie 2.掌握服务端会话跟踪技术Sesssion 1.会话跟踪技术介绍 会话&#xff1a;用户打开浏览器&#xff0c;访问web服务器的资源&#xff0c;会话建立&#xff0c;直到有一方断…...

Springboot设置Https

1、修改配置文件application.yml&#xff0c;并将*.jks放到resource目录下。 server:port: 8080ssl:key-store: classpath:*.jkskey-store-password: *key-store-type: JKSenabled: truekey-alias: boe.com.cn2、添加http转https的配置 Configuration public class TomcatCon…...

Windows 使用 Linux 子系统,轻轻松松安装多个linux

Windows Subsystem for Linux WSL 简称WSL,是一个在Windows 10\11上能够运行原生Linux二进制可执行文件&#xff08;ELF格式&#xff09;的兼容层。它是由微软与Canonical公司合作开发&#xff0c;其目标是使纯正的Ubuntu、Debian等映像能下载和解压到用户的本地计算机&#…...

中级课程——弱口令(认证崩溃)

文章目录 什么是弱口令密码生成器分类暴力破解万能密码测试环境工具 什么是弱口令 密码生成器 分类 暴力破解 万能密码 or true --测试环境 工具 九头蛇&#xff0c;超级弱口令爆破工具&#xff0c;bp&#xff0c;...

web自动化测试进阶篇05 ——— 界面交互场景测试

&#x1f60f;作者简介&#xff1a;博主是一位测试管理者&#xff0c;同时也是一名对外企业兼职讲师。 &#x1f4e1;主页地址&#xff1a;【Austin_zhai】 &#x1f646;目的与景愿&#xff1a;旨在于能帮助更多的测试行业人员提升软硬技能&#xff0c;分享行业相关最新信息。…...

NICE-SLAM: Neural Implicit Scalable Encoding for SLAM论文阅读

论文信息 标题&#xff1a;NICE-SLAM: Neural Implicit Scalable Encoding for SLAM 作者&#xff1a;Zihan Zhu&#xff0c; Songyou Peng&#xff0c;Viktor Larsson — Zhejiang University 来源&#xff1a;CVPR 代码&#xff1a;https://pengsongyou.github.io/nice-slam…...

cmake 配置Visual studio的调试命令

配置代码如截图&#xff1a; set_property(TARGET ${TARGET_NAME} PROPERTY VS_DEBUGGER_COMMAND "./consoleTest.exe") set_property(TARGET ${TARGET_NAME} PROPERTY VS_DEBUGGER_COMMAND_ARGUMENTS "./config/labelDriver.cfg") set_propert…...

MPDIoU: A Loss for Efficient and Accurate Bounding BoxRegression--论文学习笔记

超越GIoU/DIoU/CIoU/EIoU MPDIoU让YOLOv7和YOLACT双双涨点 目标检测上的指标对比&#xff1a; 论文地址&#xff1a; [2307.07662] MPDIoU: A Loss for Efficient and Accurate Bounding Box Regression (arxiv.org) 摘要 边界框回归&#xff08;Bounding Box Regression&am…...

【Uniapp 的APP热更新】

Uniapp 的APP热更新功能依赖于其打包工具 HBuilder&#xff0c;具体步骤如下&#xff1a; 1. 在 HBuilder 中构建并打包出应用程序 具体步骤&#xff1a; 1.点击发行&#xff0c;点击制作wgt包 2.根据需求修改文件储存路径和其他配置&#xff0c;点击确定 3.等待打包完成&a…...

MySQL主从复制配置

Mysql的主从复制至少是需要两个Mysql的服务,当然Mysql的服务是可以分布在不同的服务器上,也可以在一台服务器上启动多个服务。 (1)首先确保主从服务器上的Mysql版本相同 (2)在主服务器上,创建一个充许从数据库来访问的用户slave,密码为:123456 ,然后使用REPLICATION SLAV…...

Linux - 添加普通用户为信任用户

1.添加用户 在Linux系统中&#xff0c;可以使用以下步骤添加用户&#xff1a; 打开终端并以root用户身份登录 输入以下命令以创建新用户&#xff08;请将username替换为您想要创建的用户名&#xff09;&#xff1a; adduser username 设置该用户的密码&#xff0c;使用以下命…...

flask----路由系统

# 1 flask路由系统是基于装饰器的&#xff1a;参数如下 # 2 转换器&#xff1a; # 3 路由系统本质 # 4 endpoint 不传会怎么样,不传会以视图函数的名字作为值&#xff0c;但是如果加了装饰器&#xff0c;所有视图函数名字都是inner&#xff0c;就会出错&#xff0c;使用wrapp…...

驶向专业:嵌入式开发在自动驾驶中的学习之道

导语: 自动驾驶技术在汽车行业中的快速发展为嵌入式开发领域带来了巨大的机遇。作为自动驾驶的核心组成部分&#xff0c;嵌入式开发在驱动汽车的智能化和自主性方面发挥着至关重要的作用。本文将探讨嵌入式开发的学习方向、途径以及未来在自动驾驶领域中的展望。 一、学习方向:…...

Go语言入门:从零开始的快速指南(一)

文章目录 引言Go语言的诞生背景Go 语言的特性安装Go语言环境集成开发环境安装第一个Go程序Go 源代码的特征解读 引言 Go语言&#xff08;也称为Golang&#xff09;是一种开源的、静态类型的编程语言&#xff0c;由Google开发。它的设计目标是简单、高效、安全、并且易于学习和…...

Windows7+内网, 安装高版本nodejs,使用vite+vue3+typescript开发项目

前言&#xff1a;vite只支持高版本的nodejs&#xff0c;而高版本的nodejs只支持windows8及以上&#xff0c;且vite还对浏览器版本有兼容问题。以下均为vite官网截图 1、安装好低版本的nodejs win7系统建议安装13.及以下&#xff0c;我的是12.12.0这个版本。nodejs低版本官网下载…...

【C语言day14】

#include<stdio.h>int fun(char* s) {char* t s;while (*t);return(t - s); }int main() {char s[] "abc";int n fun(s);printf("%d\n", n);//4return 0; }循环在*t为0时停止&#xff0c;同时t&#xff0c;t最后会停在字符串结束的’\0’之后的一…...

暑假刷题第19天--8/1

170. 加成序列 - AcWing题库&#xff08;dfs迭代加深--重点理解&#xff09; #include<iostream> using namespace std; int n; int a[11]; int dfs(int x,int h){if(x>h1)return 0;if(a[x-1]n)return 1;bool st[130]{};for(int i1;i<x-1;i){for(int j1;j<i;j)…...

Java开发中的------修改密码+忘记密码

目录 1.修改密码 客户端响应 前端vue 后端 controller层 ServiceImpl实现层 2.忘记密码 客户端响应 后端 controller层 serviceImpl实现层 本章需要准备&#xff1a;springcloud项目&#xff0c;依赖&#xff0c;数据库.... 数据库SQL SET FOREIGN_KEY_CHECKS0;-- -…...

ffmpeg安装

简介 FFmpeg是一个开源的音视频处理库&#xff0c;它提供了一系列的工具和API&#xff0c;可以用于处理音视频文件。你可以使用FFmpeg的命令行工具来执行各种音视频处理操作&#xff0c;比如转码、剪辑、合并等。FFmpeg的命令格式通常是&#xff1a;ffmpeg [全局选项] {[输入文…...

Mac电脑目录

System&#xff08;系统&#xff09;Applications&#xff08;应用程序&#xff09;应用程序目录&#xff0c;默认所有的GUI应用程序都安装在这里User&#xff08;用户&#xff09;存放用户的个人资料和配置。每个用户有自己的单独目录Library&#xff08;资料库&#xff09;系…...

微信小程序之bind和catch

这两个呢&#xff0c;都是绑定事件用的&#xff0c;具体使用有些小区别。 官方文档&#xff1a; 事件冒泡处理不同 bind&#xff1a;绑定的事件会向上冒泡&#xff0c;即触发当前组件的事件后&#xff0c;还会继续触发父组件的相同事件。例如&#xff0c;有一个子视图绑定了b…...

java 实现excel文件转pdf | 无水印 | 无限制

文章目录 目录 文章目录 前言 1.项目远程仓库配置 2.pom文件引入相关依赖 3.代码破解 二、Excel转PDF 1.代码实现 2.Aspose.License.xml 授权文件 总结 前言 java处理excel转pdf一直没找到什么好用的免费jar包工具,自己手写的难度,恐怕高级程序员花费一年的事件,也…...

【SQL学习笔记1】增删改查+多表连接全解析(内附SQL免费在线练习工具)

可以使用Sqliteviz这个网站免费编写sql语句&#xff0c;它能够让用户直接在浏览器内练习SQL的语法&#xff0c;不需要安装任何软件。 链接如下&#xff1a; sqliteviz 注意&#xff1a; 在转写SQL语法时&#xff0c;关键字之间有一个特定的顺序&#xff0c;这个顺序会影响到…...

Spring数据访问模块设计

前面我们已经完成了IoC和web模块的设计&#xff0c;聪明的码友立马就知道了&#xff0c;该到数据访问模块了&#xff0c;要不就这俩玩个6啊&#xff0c;查库势在必行&#xff0c;至此&#xff0c;它来了。 一、核心设计理念 1、痛点在哪 应用离不开数据&#xff08;数据库、No…...

【HarmonyOS 5 开发速记】如何获取用户信息(头像/昵称/手机号)

1.获取 authorizationCode&#xff1a; 2.利用 authorizationCode 获取 accessToken&#xff1a;文档中心 3.获取手机&#xff1a;文档中心 4.获取昵称头像&#xff1a;文档中心 首先创建 request 若要获取手机号&#xff0c;scope必填 phone&#xff0c;permissions 必填 …...

MySQL账号权限管理指南:安全创建账户与精细授权技巧

在MySQL数据库管理中&#xff0c;合理创建用户账号并分配精确权限是保障数据安全的核心环节。直接使用root账号进行所有操作不仅危险且难以审计操作行为。今天我们来全面解析MySQL账号创建与权限分配的专业方法。 一、为何需要创建独立账号&#xff1f; 最小权限原则&#xf…...

基于Springboot+Vue的办公管理系统

角色&#xff1a; 管理员、员工 技术&#xff1a; 后端: SpringBoot, Vue2, MySQL, Mybatis-Plus 前端: Vue2, Element-UI, Axios, Echarts, Vue-Router 核心功能&#xff1a; 该办公管理系统是一个综合性的企业内部管理平台&#xff0c;旨在提升企业运营效率和员工管理水…...

根目录0xa0属性对应的Ntfs!_SCB中的FileObject是什么时候被建立的----NTFS源代码分析--重要

根目录0xa0属性对应的Ntfs!_SCB中的FileObject是什么时候被建立的 第一部分&#xff1a; 0: kd> g Breakpoint 9 hit Ntfs!ReadIndexBuffer: f7173886 55 push ebp 0: kd> kc # 00 Ntfs!ReadIndexBuffer 01 Ntfs!FindFirstIndexEntry 02 Ntfs!NtfsUpda…...

Linux系统部署KES

1、安装准备 1.版本说明V008R006C009B0014 V008&#xff1a;是version产品的大版本。 R006&#xff1a;是release产品特性版本。 C009&#xff1a;是通用版 B0014&#xff1a;是build开发过程中的构建版本2.硬件要求 #安全版和企业版 内存&#xff1a;1GB 以上 硬盘&#xf…...

【安全篇】金刚不坏之身:整合 Spring Security + JWT 实现无状态认证与授权

摘要 本文是《Spring Boot 实战派》系列的第四篇。我们将直面所有 Web 应用都无法回避的核心问题&#xff1a;安全。文章将详细阐述认证&#xff08;Authentication) 与授权&#xff08;Authorization的核心概念&#xff0c;对比传统 Session-Cookie 与现代 JWT&#xff08;JS…...