AuthenticationAndAuthorization
基础 身份验证(AuthN):“你是谁?” (身份)。 授权 (AuthZ): “你可以做什么?” (权限)。 📦 关键技术1. 会话(有状态) 它是什么:会话是一种服务器端机制,用于在无状态协议中跨多个 HTTP 请求记住用户。 它是如何工作的: 用户使用凭据登录。 服务器验证凭据并创建会话。 服务器将会话数据(例如,用户 ID、角色、登录状态)存储在 Redis/DB/内存中。 服务器通过 cookie 向客户端发送 session_id。 对于每个后续请求(例如,/profile),浏览器会自动通过 cookie 将 session_id 发送回服务器。 服务器验证 session_id、检索会话数据并授权用户。 机制:服务器将会话数据存储在Redis/DB/内存中;客户端仅将 session_id 存储在 cookie 中。 用例:需要高安全性、服务器端控制和即时会话撤销的 Web 应用程序(例如登录系统、管理面板、仪表板)。 优点: 安全(敏感数据保留在服务器上) 易于使会话失效(...
为什么动态代理对象proxy的System.out.println(proxy)与System.out.println(proxy.getClass)的输出结果不同
为什么动态代理对象proxy的System.out.println(proxy)与System.out.println(proxy.getClass)的输出结果不同起因在学习Spring的AOP面向切面编程时,有这么一个例子 Calculator接口 123456public interface Calculator { int add(int a, int b); int sub(int a, int b); int mul(int a, int b); int div(int a, int b);} Calculator的实现类 123456789101112131415@Servicepublic class CalculatorImpl implements Calculator { public int add(int a, int b) { return a + b; } public int sub(int a, int b) { re...
tomcat-note
Tomcat NoteServlet 容器和 Spring/SpringMVC 容器之间的关系Tomcat&Jetty 在启动时给每个 Web 应用创建一个全局的上下文环境,这个上下文就是 ServletContext,其为后面的 Spring 容器提供宿主环境。 Tomcat&Jetty 在启动过程中触发容器初始化事件,Spring 的 ContextLoaderListener 会监听到这个事件,它的 contextInitialized 方法会被调用,在这个方法中,Spring 会初始化全局的 Spring 根容器,这个就是 Spring 的 IoC 容器,IoC 容器初始化完毕后,Spring 将其存储到 ServletContext 中,便于以后来获取。 Tomcat&Jetty 在启动过程中还会扫描 Servlet,一个 Web 应用中的 Servlet 可以有多个,以 SpringMVC 中的 DispatcherServlet 为例,这个 Servlet 实际上是一个标准的前端控制器,用以转发、匹配、处理每个 Servlet 请求...
ssm-code
SSM整合复用代码片段pom.xml12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&q...
springmvc-notes
SpringMVC笔记SpringMVC简介Spring 为展现层提供的基于 MVC 设计理念的优秀的 Web 框架,是目前最主流的 MVC 框架之一 SpringMVC属于Spring框架中的web模块 HelloWorld流程:1 导包 1234567891011121314日志记录commons-logging-1.1.3.jar支持注解spring-aop-4.0.0.RELEASE.jarSpring核心容器模块spring-beans-4.0.0.RELEASE.jarspring-context-4.0.0.RELEASE.jarspring-core-4.0.0.RELEASE.jarspring-expression-4.0.0.RELEASE.jarSpring Web模块spring-web-4.0.0.RELEASE.jarspring-webmvc-4.0.0.RELEASE.jar 2 写配置 配置springmvc的前端控制器,指定springmvc配置文件位置 WEB-INF/web.xml: 12345678910111213141...
springcloud-note
Spring Cloud NoteEurekaEureka ServerEureka Server Startup Class1234567@SpringBootApplication@EnableEurekaServerpublic class EurekaMain7002 { public static void main(String[] args) { SpringApplication.run(EurekaMain7002.class, args); }} Eureka Server POM1234<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId></dependency> Eureka Server applicatio...
spring-notes
Spring 笔记Spring模块 pom配置1234567<dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>5.2.4.RELEASE</version> </dependency></dependencies> IOC/DIIOC:(Inversion(反转) Of Control) 控制反转 控制: 资源的获取方式:主动式:创建需要的对象 1Person person = new Person(); 被动式:资源的获取不是我们自己创建,而是交给一个容器来创建和设置 123456BookServlet{ BookService bs; public void test0...
mybatis-plus-notes
Mybatis Plus 笔记Mybatis Plus 介绍框架结构 特性 无入侵、损耗小、强大的 CRUD 操作 支持Lambda形式调用、支持多种数据库(MySQL、Oracle) 支持主键自动生成、支持 ActiveRecord 模式 支持自定义全局通用操作、支持关键词自动转义 内置代码生成器、内置分页插件、内置性能分析插件 内置全局拦截插件、内置 SQL 注入剥离器 HelloWorld 执行建表 SQL 12345678910111213141516171819# 创建用户表CREATE TABLE user ( id BIGINT(20) PRIMARY KEY NOT NULL COMMENT '主键', name VARCHAR(30) DEFAULT NULL COMMENT '姓名', age INT(11) DEFAULT NULL COMMENT '年龄', email VARCHAR(50) DEFAULT NULL COMMENT '邮箱', ...
mybatis-notes
Mybatis笔记自定义Mybatis框架配置文件相关类结构及作用 Database Access Object相关类 mybatis核心类 动态代理 Mybatis的配置文件全局配置文件一般放于项目根目录下,名为SqlMapConfig.xml,其中记录了数据库的连接信息(driver url username password),以及映射文件的位置 配置文档的顶层结构如下: configuration(配置) properties(属性) settings(设置) typeAliases(类型别名) typeHandlers(类型处理器) objectFactory(对象工厂) plugins(插件) environments(环境配置) environment(环境变量) transactionManager(事务管理器) dataSource(数据源) databaseIdProvider(数据库厂商标识) mappers(映射器) 示例全局配置文件: 1234567891011121314151617181920212223242526272829...
maven-notes
Maven笔记设置代理12345678910111213141516171819<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd"> ... <proxies> <proxy> <id>myproxy</id> <active>true</active> <protocol>http</protocol> <host>proxy....