Compare commits

...

10 Commits

Author SHA1 Message Date
762e8c7123 合集笔记体检 2025-10-26 12:37:25 +08:00
e1879902ea add tcp 2025-09-22 22:55:55 +08:00
92dd52fbb4 posts 2025-09-22 15:33:12 +08:00
49067e6b19 Merge branch 'master' of github.com:meowrain/fuwari-blog 2025-09-22 13:23:35 +08:00
b41b2f9c51 add 2025-09-22 13:15:44 +08:00
c92882bcbf add 2025-09-22 11:12:37 +08:00
8cf9f23f64 排序 2025-09-22 00:05:54 +08:00
81508c5b5d add posts 2025-09-21 18:38:36 +08:00
3cc67272a6 add files 2025-09-20 22:12:49 +08:00
ffb1e8eac5 add 疑难杂症 2025-09-20 22:09:47 +08:00
70 changed files with 94641 additions and 0 deletions

0
public/api/i/2025/09/18/119exsd-1.webp Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 206 KiB

After

Width:  |  Height:  |  Size: 206 KiB

0
public/api/i/2025/09/20/10gf9ih-1.webp Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

0
public/api/i/2025/09/20/10gsu60-1.webp Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

0
public/api/i/2025/09/20/10h4100-1.webp Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

0
public/api/i/2025/09/20/10hjla3-1.webp Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 48 KiB

0
public/api/i/2025/09/20/10hnekj-1.webp Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 47 KiB

0
public/api/i/2025/09/20/10i2nlq-1.webp Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 46 KiB

0
public/api/i/2025/09/20/10i6pio-1.webp Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
public/web/bfg-1.15.0.jar Normal file

Binary file not shown.

View File

@@ -0,0 +1,17 @@
---
title: SpringMVC工作流程
published: 2025-09-22
description: ''
image: ''
tags: [SpringMVC,DispatcherServlet]
category: 'Java > Spring'
draft: false
lang: ''
---
![](https://blog.meowrain.cn/api/i/2025/09/22/ovqrfw-1.webp)
![](https://blog.meowrain.cn/api/i/2025/09/22/oz4od3-1.webp)

View File

@@ -0,0 +1,141 @@
---
title: Spring中拦截器和过滤器的区别
published: 2025-09-22
description: ''
image: ''
tags: [SpringMVC,拦截器,过滤器]
category: 'Java > Spring'
draft: false
lang: ''
---
https://www.mianshiya.com/question/1907425766060380162#heading-0
![](https://blog.meowrain.cn/api/i/2025/09/22/p1p5sy-1.webp)
# 过滤器
## 实现机制
过滤器是Servlet规范的一部分独立于Spring存在主要用于过滤请求和响应可以对所有类型的请求进行处理。
## 使用范围
可以过滤所有的请求,包括静态资源,jsp,html等因为它在Servlet容器层面生效。
## 配置方法
需要实现Filter接口通过标准的Servlet配置方式进行注册
https://www.cnblogs.com/xfeiyun/p/15790555.html
https://juejin.cn/post/7000950677409103880
![](https://blog.meowrain.cn/api/i/2025/09/22/nk3hly-1.webp)
![](https://blog.meowrain.cn/api/i/2025/09/22/nker0x-1.webp)
![](https://blog.meowrain.cn/api/i/2025/09/22/nkq0yb-1.webp)
![](https://blog.meowrain.cn/api/i/2025/09/22/nl2e0e-1.webp)
![](https://blog.meowrain.cn/api/i/2025/09/22/nq0cv2-1.webp)
![](https://blog.meowrain.cn/api/i/2025/09/22/nq24rg-1.webp)
![](https://blog.meowrain.cn/api/i/2025/09/22/nq3xj5-1.webp)
![](https://blog.meowrain.cn/api/i/2025/09/22/nqp845-1.webp)
![](https://blog.meowrain.cn/api/i/2025/09/22/nqzx04-1.webp)
![](https://blog.meowrain.cn/api/i/2025/09/22/nr35ne-1.webp)
## 执行顺序
先于拦截器执行因为过滤器作用于Servlet容器层面拦截器作用在Spring MVC 的处理器映射器找到控制器前或者后执行。
## 功能侧重
侧重于过滤请求和响应的内容,比如设置编码格式,安全控制等。
# 拦截器
## 实现机制
拦截器是Spring框架的一部分基于Java的反射机制实现主要针对的是Handler的调用
## 使用范围
主要用于拦截访问DispathcherServlet的请求通常只适用于Spring MVC的应用程序中的请求处理方法。
## 配置方式
需要实现org.springframework.web.servlet.HandlerInterceptor接口并在Spring配置文件中进行注册。
可以通过实现WebMvcConfigurer接口的addInterceptors方法来进行注册。
![](https://blog.meowrain.cn/api/i/2025/09/22/p51up4-1.webp)
```java
package com.example.interceptor;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
/**
* @author wipe
* @version 1.0
*/
public class MyInterceptor1 implements HandlerInterceptor {
@Override//目标资源方法执行前执行。 返回true放行 返回false不放行
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
System.out.println("MyInterceptor1 ... preHandle");
return true;
}
@Override//目标资源方法执行后执行
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
System.out.println("MyInterceptor1 ... postHandle");
}
@Override//视图渲染完毕后执行,最后执行
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
System.out.println("MyInterceptor1 ... afterCompletion");
}
}
```
```java
package com.example.config;
import com.example.filter.MyFilter1;
import com.example.filter.MyFilter2;
import com.example.interceptor.MyInterceptor1;
import com.example.interceptor.MyInterceptor2;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* @author wipe
* @version 1.0
*/
@Configuration
public class MyConfig implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
// 添加拦截器,并指定执行顺序,也可以通过将拦截器声明成 bean 对象,然后通过 @Order 注解或者实现 Order 接口指定执行顺序
registry.addInterceptor(new MyInterceptor1()).order(1);
registry.addInterceptor(new MyInterceptor2()).order(2);
}
@Bean// 这样配置可以指定过滤器的执行顺序
public FilterRegistrationBean<MyFilter1> myFilter1() {
FilterRegistrationBean<MyFilter1> filter = new FilterRegistrationBean<>();
filter.setFilter(new MyFilter1());
filter.addUrlPatterns("/*");
filter.setOrder(1);
return filter;
}
@Bean
public FilterRegistrationBean<MyFilter2> myFilter2() {
FilterRegistrationBean<MyFilter2> filter = new FilterRegistrationBean<>();
filter.setFilter(new MyFilter2());
filter.addUrlPatterns("/*");
filter.setOrder(2);
return filter;
}
}
```
也可以直接用@Component注册Interceptor
## 执行顺序
可以指定多个拦截器之间的执行顺序通过实现Ordered接口或者使用@Order注解来控制
## 功能侧重
侧重于业务逻辑的前置检查,权限验证,日志记录等。

16774
src/content/posts/合集/DB.md Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,164 @@
---
title: Cookie和Session的区别
published: 2025-09-21
description: ''
image: ''
tags: [Cookie,Session]
category: '工作'
draft: false
lang: ''
---
# Cookie
Cookie是存储在用户浏览器端的一个小型数据文件用于跟踪和保护用户的状态信息。
主要用于保持用户的登录状态,跟踪用户行为,存储用户偏好等。
**是存储在浏览器的**
## 为什么需要Cookie
HTTP协议是无状态的意味着每次请求都是独立的服务器不会记住用户之前的行为。
用户登录后,服务器无法知道后续请求是否来自同一个用户。
就像你登录了一个电商网站(如淘宝),假如 HTTP是无状态的那么你每次刷新页面或跳转到其他页面时系统都会提示“请重新登录”这是因为服务器无法记住你之前的登录状态。
而通过Cookie服务器在用户登录成功后设置一个标识。浏览器会将这个标识保存下来并在后续请求中自动附加到请求头中服务器通过解析这个标识就能知道用户已登录。
浏览器在每次HTTP请求中自动携带Cookie信息服务器通过解析这些信息识别用户身份。虽然HTTP协议本身无状态但通过Cookie的“附加行为”实现了有状态的交互。
## 如何设置Cookie
### SpringBoot
#### 在 Controller 中设置 Cookie
```java
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class CookieController {
@GetMapping("/set-cookie")
public String setCookie(HttpServletResponse response) {
Cookie cookie = new Cookie("token", "abc123");
cookie.setPath("/"); // 设置路径(整个项目可用)
cookie.setMaxAge(60 * 60); // 有效期 1 小时
cookie.setHttpOnly(true); // 防止 JS 读取,提升安全性
cookie.setSecure(false); // true 代表仅 https 传输
response.addCookie(cookie); // 写入响应头
return "Cookie 已设置!";
}
}
```
#### 在 Response Header 中手动写入 Cookie
有时需要更细控制,可以直接操作 Set-Cookie 响应头:
```java
@GetMapping("/set-cookie-header")
public String setCookieHeader(HttpServletResponse response) {
response.addHeader("Set-Cookie", "sessionId=xyz789; Path=/; HttpOnly; Max-Age=3600");
return "Header Cookie 已设置!";
}
```
#### 读取 Cookie
使用 @CookieValue
```java
@GetMapping("/get-cookie")
public String getCookie(@CookieValue(value = "token", defaultValue = "null") String token) {
return "当前 token = " + token;
}
```
```java
@GetMapping("/get-cookie2")
public String getCookie2(HttpServletRequest request) {
Cookie[] cookies = request.getCookies();
if (cookies != null) {
for (Cookie c : cookies) {
if ("token".equals(c.getName())) {
return "找到 token: " + c.getValue();
}
}
}
return "未找到 token";
}
```
### Cookie组成
用户可通过 f12打开控制台然后应用->Cookie->找到当前地址就能看到当前的Cookie 信息。
![](https://blog.meowrain.cn/api/i/2025/09/21/xev89u-1.webp)
- `key=value`: 核心数据
- `Set-Cookie`字段: 服务器通过这个字段定义Cookie的内容
- `Path=/` 指定Cookie的而作用路径/表示所有路径均可访问)
- `HttpOnly`: 防止JavaScript 访问Cookie提高安全性
- `Secure`: 要求Cookie仅能通过HTTPS传输
- `Max-Age`: 设置Cookie在多久后过期
- `Expires` 设置Cookie在指定时间过期
- `Domain` 作用域指定Cookie所属的域名允许跨子域名共享
**Max-Age** 和**Expires**是设置Cookie过期时间的两种方式。
![](https://blog.meowrain.cn/api/i/2025/09/21/x7ivoo-1.webp)
![](https://blog.meowrain.cn/api/i/2025/09/21/x7kr9o-1.webp)
---
![](https://blog.meowrain.cn/api/i/2025/09/21/xfy5w7-1.webp)
![](https://blog.meowrain.cn/api/i/2025/09/21/xfwwfm-1.webp)
![](https://blog.meowrain.cn/api/i/2025/09/21/xfutn8-1.webp)
![](https://blog.meowrain.cn/api/i/2025/09/21/xg132o-1.webp)
![](https://blog.meowrain.cn/api/i/2025/09/21/xg1u42-1.webp)
![](https://blog.meowrain.cn/api/i/2025/09/21/xg3flm-1.webp)
## Cookie按照生命周期分为两种
会话期cookie是最简单的cookie浏览器关闭后会被自动删除。会话期cookie不需要指定过期时间Expires或者有效期Max-Age)。需要注意的是有些浏览器提供了会话恢复功能这种情况即使关闭了浏览器会话期cookie也会被保留下来这会导致cookie的生命周期无限期延长
持久性cookie的生命周期取决于过期时间Expires或者有效期Max-Age指定的一段时间。
当Cookie的过期时间被设定时设定的日期和时间只与客户端相关而不是服务端。
![](https://blog.meowrain.cn/api/i/2025/09/21/x6dk9p-1.webp)
![](https://blog.meowrain.cn/api/i/2025/09/21/x6ftip-1.webp)
![](https://blog.meowrain.cn/api/i/2025/09/21/x6htww-1.webp)
## Cookie过期时间配置
**Max-Age** 和**Expires**是设置Cookie过期时间的两种方式。
![](https://blog.meowrain.cn/api/i/2025/09/21/x7ivoo-1.webp)
![](https://blog.meowrain.cn/api/i/2025/09/21/x7kr9o-1.webp)
> 两者都用于设置“持久级 Cookie”会话级 Cookie 不设置它们)
> 同时存在时Max-Age 优先
## Cookie大小限制
- 单个Cookie最大约为4KB
## Cookie数量限制
浏览器对同一域名的Cookie数量有限制如Chrome为200个
## 安全建议:
永远不要在Cookie中存储敏感信息如密码改用Token或Session ID。
始终启用HttpOnly和Secure防止XSS和中间人攻击。
## Cookie优缺点和注意事项
![](https://blog.meowrain.cn/api/i/2025/09/21/xhd3rc-1.webp)
# Session
session是另一种记录客户状态的机制不同的是Cookie保存在客户端浏览器中而session保存在服务器上,客户端浏览器访问服务器的时候服务器把客户端信息以某种形式记录在服务器上这就是session。客户端浏览器再次访问时只需要从该Session中查找该客户的状态就可以了;
## 安全性
![](https://blog.meowrain.cn/api/i/2025/09/22/ia3jrw-1.webp)
## Session 的工作流程
![](https://blog.meowrain.cn/api/i/2025/09/22/i8sx9o-1.webp)
## 大小
Session是无大小限制的
## 缺陷
![](https://blog.meowrain.cn/api/i/2025/09/22/ib38t6-1.webp)
![](https://blog.meowrain.cn/api/i/2025/09/22/ib9eq3-1.webp)
![](https://blog.meowrain.cn/api/i/2025/09/22/ib4quq-1.webp)
## Cookie和Session的区别
![](https://blog.meowrain.cn/api/i/2025/09/22/ibdvwc-1.webp)
![](https://blog.meowrain.cn/api/i/2025/09/22/ibpwz6-1.webp)

View File

@@ -0,0 +1,12 @@
---
title: 常见开发模型
published: 2025-09-21
description: ''
image: ''
tags: [开发模型,瀑布模型,原型法,V模型,螺旋模型]
category: '工作'
draft: false
lang: ''
---
![](https://blog.meowrain.cn/api/i/2025/09/21/wedsm1-1.webp)

View File

@@ -0,0 +1,133 @@
---
title: 排序算法
published: 2025-09-21
description: ''
image: ''
tags: []
category: '数据结构与算法'
draft: false
lang: ''
---
# 冒泡排序
![](https://blog.meowrain.cn/api/i/2025/09/21/12fnqrb-1.webp)
算法复杂度: O(n^2)
稳定性: 是稳定排序算法,相等的元素不会变换位置
```go
package main
import "fmt"
func main() {
var n int
fmt.Scan(&n)
arr := make([]int,n)
for i:= range arr {
fmt.Scan(&arr[i])
}
bubbleSort(arr)
for i,v := range arr {
if i > 0 {
fmt.Print(" ")
}
fmt.Print(v)
}
}
func bubbleSort(arr []int) {
n := len(arr)
for i:=0;i<n-1;i++ {
for j:=0;j<n-1-i;j++ {
if arr[j] > arr[j + 1] {
arr[j],arr[j + 1] = arr[j + 1],arr[j]
}
}
}
}
```
```java
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] arr = new int[n];
for(int i = 0;i<n;i++) {
arr[i] = sc.nextInt();
}
bubbleSort(arr);
for(int i = 0;i<n;i++) {
System.out.print(arr[i] + " ");
}
}
static void bubbleSort(int[] arr) {
int n = arr.length;
for(int i = 0;i<n - 1;i++) {
for(int j = 0;j<n - 1 - i;j++) {
int temp = arr[j];
if(arr[j + 1] < arr[j]) {
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
}
}
```
# 快速排序
## 时间复杂度
平均时间复杂度: O(nlogn)
最坏时间复杂度: O(n^2) 在已经排序或者大部分已排序的情况下
最好时间复杂度: O(nlogn)
## 空间复杂度
是原地排序只占用少量的额外空间空间复杂度是O(logn),主要是递归调用栈的空间
## 稳定性
快速排序是 不稳定 排序。
采用分治策略排列元素,把数组分成两个子数组,递归排序,再合并。
分区的基本思想
分区的目标选择一个基准元素pivot将数组重新排列使得
## 分区思想
基准左边的所有元素 <= 基准
基准右边的所有元素 >= 基准
基准本身位于最终的正确位置
```go
package main
import "fmt"
func main() {
var n int
fmt.Scan(&n)
arr := make([]int,n)
for i:= range arr {
fmt.Scan(&arr[i])
}
quickSort(arr,0,len(arr) - 1)
}
func quickSort(arr []int,low int,high int) {
if low < high {
pi := partition(arr,low,high)
quickSort(arr,low,pi - 1)
quickSort(arr,pi + 1,high)
}
}
func partition(arr []int,low int,high int) int {
pivot := arr[high]
i := low - 1
for j := low;j < high;j++ {
if arr[j] <= pivot {
i++
arr[i],arr[j] = arr[j],arr[i]
}
}
arr[i + 1],arr[high] = arr[high],arr[i + 1]
return i + 1
}
```

View File

@@ -0,0 +1,31 @@
---
title: Git不小心提交了100M以上文件导致无法提交解决方案
published: 2025-09-20
description: ''
image: ''
tags: []
category: '疑难杂症'
draft: false
lang: ''
---
![](https://blog.meowrain.cn/api/i/2025/09/20/10gf9ih-1.webp)
![](https://blog.meowrain.cn/api/i/2025/09/20/10h4100-1.webp)
![](https://blog.meowrain.cn/api/i/2025/09/20/10hjla3-1.webp)
![](https://blog.meowrain.cn/api/i/2025/09/20/10hnekj-1.webp)
![](https://blog.meowrain.cn/api/i/2025/09/20/10i2nlq-1.webp)
可以直接用这个Scala写的bfg,点击下载:
https://blog.meowrain.cn/web/bfg-1.15.0.jar
https://github.com/rtyley/bfg-repo-cleaner
文档: https://rtyley.github.io/bfg-repo-cleaner/
![](https://blog.meowrain.cn/api/i/2025/09/20/10gsu60-1.webp)
![](https://blog.meowrain.cn/api/i/2025/09/20/10i6pio-1.webp)

View File

@@ -0,0 +1,36 @@
---
title: HTTP中GET和POST的区别是什么
published: 2025-09-21
description: ''
image: ''
tags: [计算机网络,HTTP]
category: '计算机网络'
draft: false
lang: ''
---
# HTTP中GET和POST的区别是什么
## 从HTTP定义看
从HTTP定义看
GET用来获取资源。通常用来请求数据不改变服务器状态
POST用来提交数据到服务器通常会改变服务器状态或者产生副作用比如创建或者更新资源
## 参数传递
GET是通过URL拼接来实现参数传递的暴露在请求URL中有可见性长度有限。2048字节
POST把参数放在请求体里面通常不可见而且长度理论上也没有限制更适合传递大量数据nginx默认限制为1M
## 安全性
GET 参数可见,数据容易暴露在浏览器历史记录,日志和缓存中,不适合传递敏感信息。
POST 数据放在请求体中相对安全但需要HTTPS才能保证数据加密传输。
## 幂等性
GET: 幂等的(重复请求不会改变服务器状态)
POST: 非幂等的(多次请求可能导致重复创建资源或者执行多次相同的操作)
## RESTful API设计中的角色分工
- GET 用来查询或者检索资源数据
- POST 用来创建资源或者执行某些动作
- PUT和PATCH 用来更新资源 PUT替换整个资源PATCH更新部分资源
- DELETE: 用来删除资源。

View File

@@ -0,0 +1,32 @@
---
title: HTTP请求中包含哪些内容请求头和请求体有哪些内容
published: 2025-09-21
description: ''
image: ''
tags: [HTTP,计算机网络,请求头,请求体]
category: '计算机网络'
draft: false
lang: ''
---
# HTTP请求由以下几部分组成
- 请求行请求方法请求资源路径HTTP协议版本
- 请求头
- 空行
- 请求体
# 常见请求头与请求体
![](https://blog.meowrain.cn/api/i/2025/09/21/uduata-1.webp)
![](https://blog.meowrain.cn/api/i/2025/09/21/uab784-1.webp)
![](https://blog.meowrain.cn/api/i/2025/09/21/ua8smj-1.webp)
![](https://blog.meowrain.cn/api/i/2025/09/21/u993u3-1.webp)
# URI URL URN
URI
├─ URL通过“位置+协议”定位资源)
└─ URN通过“唯一名称”标识资源与位置无关

View File

@@ -0,0 +1,22 @@
---
title: TCP/IP 四层模型
published: 2025-09-22
description: ''
image: ''
tags: []
category: '计算机网络'
draft: false
lang: ''
---
![](https://blog.meowrain.cn/api/i/2025/09/22/11abnz9-1.webp)
# TCP/IP 四层模型
TCP/IP 四层模型是一个分层网络通信模型,将网络通信过程分为四个层次,这四层分别是:
- 网络接口层 以太网WIFI,PPP
- 网络层 IP,ICMP,ARP
- 传输层 TCP,UDP
- 应用层 HTTP,FTP,SMTP
![](https://blog.meowrain.cn/api/i/2025/09/22/119q2ig-1.webp)

View File

@@ -0,0 +1,28 @@
---
title: 常见HTTP状态码
published: 2025-09-21
description: ''
image: ''
tags: [HTTP,状态码,计算机网络]
category: '计算机网络'
draft: false
lang: ''
---
# 1xx信息响应
- 100 Continue: 服务器已接收请求的初步部分,客户端应该继续请求
- 101 Switching Protocols: 服务器同意切换协议比如从HTTP切换到Webscoket
# 2xx信息响应
- 200 OK: 请求成功,服务器返回请求的资源或者数据
- 201 Created 请求成功并创建了新资源常用于POST请求
- 204 No Content: 请求成功但服务器不返回任何信息,常用于删除操作
# 3xx 重定向
- 301 Moved Permanently: 资源已永久移动到新的URL客户端应该用新URL访问。
- 302 Found: 资源临时移动到新的URL客户端应该继续使用原来的URL
## 常见重定向机制
![](https://blog.meowrain.cn/api/i/2025/09/21/ukxf35-1.webp)