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

Spring Boot项目接收前端参数的11种方式

大家好,我是。在前后端项目交互中,前端传递的数据可以通过HTTP请求发送到后端, 后端在Spring Boot中如何接收各种复杂的前端数据呢?这篇文章总结了11种在Spring Boot中接收前端数据的方式。

1 搭建项目

1.通过Spring Initializr选项创建一个项目名称为【sb_receive_param】的SpringBoot项目。

2.给项目添加Spring Web依赖。

3.在com.cy.sb_receive_param.pojo包下创建User实体类。

package com.cy.sb_receive_param.pojo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;@Data
@NoArgsConstructor
@AllArgsConstructor
public class User implements Serializable {private Integer id;private String username;private String password;private Cat cat;private List<Course> courses;
}

4.在com.cy.sb_receive_param.controller包下创建UserController类。

package com.cy.sb_receive_param.controller;
import org.springframework.web.bind.annotation.*;@RequestMapping("users")
@RestController
public class UserController {}

5.解决在前后端分离项目中的跨域问题。通过实现WebMvcConfigurer接口,并重写addCorsMappings(CorsRegistry registry)方法来实现。

package com.cy.sb_receive_param.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;@Configuration
public class CrossOriginConfig implements WebMvcConfigurer {/*** addMapping("/**"):配置可以被跨域的路径,可以任意配置,可以具体到直接请求路径* allowedOrigins("*"):允许所有的请求域名访问我们的跨域资源,可以固定单条或者多条内容,如"http://www.yx.com",只有该域名可以访问我们的跨域资源* allowedHeaders("*"):允许所有的请求header访问,可以自定义设置任意请求头信息* allowedMethods():允许所有的请求方法访问该跨域资源服务器,如GET、POST、DELETE、PUT、OPTIONS、HEAD等* maxAge(3600):配置客户端可以缓存pre-flight请求的响应的时间(秒)。默认设置为1800秒(30分钟)*/@Overridepublic void addCorsMappings(CorsRegistry registry) {registry.addMapping("/**").allowedOrigins("*").allowedHeaders("*").allowedMethods("GET", "POST", "DELETE", "PUT", "OPTIONS", "HEAD").maxAge(3600);}
}

2 Spring Boot接收前端参数方式

2.1 传非JSON数据
2.1.1 注解介绍

@RequestParam主要用于在Spring MVC后台控制层获取参数,它有三个常用参数。

参数名

描述

defaultValue

表示设置默认值

required

表示该参数是否必传

value

值表示接收传入的参数的key

@PathVariable用于将请求URL中的模板变量映射到功能处理方法的参数上,即取出URL模板中的变量作为参数。

2.1.2 案例演示

1.方式一

1.在UserController类中添加add1()请求处理方法。前端请求参数的key需和后端控制层处理请求的方法参数名称一致。

@RequestMapping("add1")
public void add1(String username, String password) {System.out.println("username=" + username + ", password=" + password);
}

2.使用ApiPost工具测试(GET和POST请求都支持)。

localhost:8080/users/add1?username=tom&password=123456

3.创建param01.html页面,通过Axios发送请求。

<!DOCTYPE html>
<html><head><meta charset="utf-8" /><title>前后端参数传递</title><script src="https://unpkg.com/vue@next"></script><script src="https://unpkg.com/axios/dist/axios.min.js"></script></head><body><div id="app"></div><script>const app = {data() {return {username: '王小虎',password: '123456'}},mounted() {axios.get('http://localhost:8888/users/add1', {params: {username: this.username,password: this.password}}).then(response => {console.log('success', response.data);}).catch(error => {console.log('fail', error.data);});}}Vue.createApp(app).mount('#app')</script></body>
</html>

2.方式二

1.在UserController类中添加add2()请求处理方法。如果前端请求参数的key与后端控制层处理请求的方法参数名称不一致,使用@RequestParam注解来解决。

@RequestMapping("add2")
public void add2(@RequestParam("name") String username, @RequestParam("pwd") String password) {System.out.println("username=" + username + ", password=" + password);
}

2.使用ApiPost工具测试(GET和POST请求都支持)。

localhost:8080/users/add2?name=tom&pwd=123456

3.创建param02.html页面,通过Axios发送请求。

<!DOCTYPE html>
<html><head><meta charset="utf-8" /><title>前后端参数传递</title><script src="https://unpkg.com/vue@next"></script><script src="https://unpkg.com/axios/dist/axios.min.js"></script></head><body><div id="app"></div><script>const app = {data() {return {username: '张小三',password: '654321'}},mounted() {axios.get('http://localhost:8888/users/add2', {params: {name: this.username,pwd: this.password}}).then(response => {console.log('success', response.data);}).catch(error => {console.log('fail', error.data);});}}Vue.createApp(app).mount('#app')</script></body>
</html>

3.接收前端传数组参数

1.在UserController类中添加delete1()请求处理方法。

@DeleteMapping("batch_delete1")
public void delete1(@RequestParam(name = "ids") List<Integer> ids) {for (Integer id : ids) {System.out.println(id);}
}

2.使用ApiPost工具测试,在【Query】选项下添加ids参数,参数值设置为1,3,5

3.使用ApiPost工具测试,在【Query】选项下添加ids参数,将参数的值单独一个个进行添加。

4.创建param03.html页面,通过Axios发送请求。

<!DOCTYPE html>
<html><head><meta charset="utf-8" /><title>前后端参数传递</title><script src="https://unpkg.com/vue@next"></script><script src="https://unpkg.com/axios/dist/axios.min.js"></script></head><body><div id="app"></div><script>const app = {data() {return {ids: [1, 3, 5]}},mounted() {axios.delete('http://localhost:8888/users/batch_delete1', {params: {ids: this.ids.join(',')}}).then(response => {console.log('success', response.data);}).catch(error => {console.log('fail', error.data);});}}Vue.createApp(app).mount('#app')</script></body>
</html>

4.方式四

1.在UserController类中添加add3()请求处理方法。前端请求参数的key需和后端控制层处理请求方法的参数pojo实体类的属性名称一致。

@RequestMapping("add3")
public void add3(User user) {System.out.println(user);
}

2.使用ApiPost工具测试(GET和POST请求都支持)。

localhost:8080/users/add3id=1&username=tom&password=123

3.创建param04.html页面,通过Axios发送请求。

<!DOCTYPE html>
<html><head><meta charset="utf-8" /><title>前后端参数传递</title><script src="https://unpkg.com/vue@next"></script><script src="https://unpkg.com/axios/dist/axios.min.js"></script></head><body><div id="app"></div><script>const app = {data() {return {id: 1,username: '王小明',password: '123456'}},mounted() {axios.get('http://localhost:8888/users/add3', {params: {id: this.id,username: this.username,password: this.password}}).then(response => {console.log('success', response.data);}).catch(error => {console.log('fail', error.data);});}}Vue.createApp(app).mount('#app')</script></body>
</html>

5.方式五

1.在UserController类中添加add4()请求处理方法。使用@PathVariable注解将请求URL中的模板变量映射到功能处理方法的参数上,如果模板变量名称和方法的参数名称不同需要在@PathVariable注解上显示的指定映射关系。

@RequestMapping("add4/{username}/{pwd}")
public void add4(@PathVariable String username, @PathVariable("pwd") String password) {System.out.println("username=" + username + ", password=" + password);
}

2.使用ApiPost工具测试(GET和POST请求都支持)。

localhost:8080/users/add4/tom/123456

3.创建param05.html页面,通过Axios发送请求。

<!DOCTYPE html>
<html><head><meta charset="utf-8" /><title>前后端参数传递</title><script src="https://unpkg.com/vue@next"></script><script src="https://unpkg.com/axios/dist/axios.min.js"></script></head><body><div id="app"></div><script>const app = {data() {return {username: '',password: '123456'}},mounted() {axios.post(`http://localhost:8888/users/add4/${this.username}/${this.password}`).then(response => {console.log('success', response.data);}).catch(error => {console.log('fail', error.data);});}}Vue.createApp(app).mount('#app')</script></body>
</html>

6.方式六

1.在UserController类中添加add5()请求处理方法。通过HttpServletRequest对象获取数据,前端请求参数的key需和getParameter(String name)方法传递的参数名称一致。

@RequestMapping("add5")
public void add5(HttpServletRequest request) {String username = request.getParameter("username");String password = request.getParameter("password");System.out.println("username=" + username + ", password=" + password);
}

2.使用ApiPost工具测试(GET和POST请求都支持)。

localhost:8080/users/add5username=tom&password=123

3.创建param06.html页面,通过Axios发送请求。

<!DOCTYPE html>
<html><head><meta charset="utf-8" /><title>前后端参数传递</title><script src="https://unpkg.com/vue@next"></script><script src="https://unpkg.com/axios/dist/axios.min.js"></script></head><body><div id="app"></div><script>const app = {data() {return {username: '',password: '123456'}},mounted() {axios.post('http://localhost:8888/users/add5', null, {params: {username: this.username,password: this.password}}).then(response => {console.log('success', response.data);}).catch(error => {console.log('fail', error.data);});}}Vue.createApp(app).mount('#app')</script></body>
</html>
2.2 传JSON数据
2.2.1 注解介绍

@RequestBody该注解会把接收到的参数转为JSON格式。如果前端通过application/json类型提交JSON格式的数据给后端控制层处理请求的方法,方法的参数必须使用@RequestBody注解进行修饰,才能接收来自前端提交的JSON数据。

2.2.2 案例演示

1.接收前端传数组参数

1.在UserController类中添加delete2()请求处理方法。

@DeleteMapping("batch_delete2")
public void delete2(@RequestBody ArrayList<Integer> ids) {for (Integer id : ids) {System.out.println(id);}
}

2.使用ApiPost工具测试,在【Body】选项选项下发送JSON格式数据[1, 3, 5]给后台。

3.创建param07.html页面,通过Axios发送请求。

<!DOCTYPE html>
<html><head><meta charset="utf-8" /><title>前后端参数传递</title><script src="https://unpkg.com/vue@next"></script><script src="https://unpkg.com/axios/dist/axios.min.js"></script></head><body><div id="app"></div><script>const app = {data() {return {ids: [1, 3, 5]}},mounted() {axios.post('http://localhost:8888/users/batch_delete2', this.ids).then(response => {console.log('success', response.data);}).catch(error => {console.log('fail', error.data);});}}Vue.createApp(app).mount('#app')</script></body>
</html>

2.单个实体接收参数

1.在UserController类中添加add6()请求处理方法。

@RequestMapping("add6")
public User add6(@RequestBody User user) {System.out.println(user);return user;
}

2.使用ApiPost工具测试,需将提交的数据类型设置为application/json格式(GET和POST请求都支持)。

{"id": 1,"username": "tom","password": "123456"
}

3.创建param08.html页面,通过Axios发送请求。

<!DOCTYPE html>
<html><head><meta charset="utf-8" /><title>前后端参数传递</title><script src="https://unpkg.com/vue@next"></script><script src="https://unpkg.com/axios/dist/axios.min.js"></script></head><body><div id="app"></div><script>const app = {data() {return {user: {username: '',password: '123456'}}},mounted() {axios.post('http://localhost:8888/users/add6', this.user).then(response => {console.log('success', response.data);}).catch(error => {console.log('fail', error.data);});}}Vue.createApp(app).mount('#app')</script></body>
</html>

3.实体嵌套实体接收参数

1.在pojo包下创建Cat实体类。

package com.cy.sb_receive_param.pojo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;@Data
@NoArgsConstructor
@AllArgsConstructor
public class Cat {private Integer id;private String breed;private String name;
}

2.在pojo包下的User实体类中声明Cat类型的属性。

package com.cy.sb_receive_param.pojo;
import lombok.Data;
import lombok.ToString;@Data
@ToString
public class User {private Integer id;private String username;private String password;private Cat cat;
}

3.在UserController类中添加add7()请求处理方法。

@RequestMapping("add7")
public User add7(@RequestBody User user) {System.out.println(user);return user;
}

4.使用ApiPost工具测试,需将提交的数据类型设置为application/json格式(GET和POST请求都支持)。

{"id": 1,"username": "","password": "123456","cat": {"id": 1,"breed": "蓝白","name": "花花"}
}

5.创建param09.html页面,通过Axios发送请求。

<!DOCTYPE html>
<html><head><meta charset="utf-8" /><title>前后端参数传递</title><script src="https://unpkg.com/vue@next"></script><script src="https://unpkg.com/axios/dist/axios.min.js"></script></head><body><div id="app"></div><script>const app = {data() {return {user: {id: 1,username: '',password: '123456',cat: {id: 1,breed: '蓝白',name: '花花'}}}},mounted() {axios.post('http://localhost:8888/users/add7', this.user).then(response => {console.log('success', response.data);}).catch(error => {console.log('fail', error.data);});}}Vue.createApp(app).mount('#app')</script></body>
</html>

4.实体嵌套List集合接收参数

1.在pojo包下创建Course实体类。

package com.cy.sb_receive_param.pojo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;@Data
@NoArgsConstructor
@AllArgsConstructor
public class Course {private Integer id;private String courseName;private String lecturer;
}

2.在pojo包下的User实体类中声明List<Course>类型的属性。

package com.cy.sb_receive_param.pojo;
import lombok.Data;
import lombok.ToString;
import java.util.List;@Data
@ToString
public class User {private Integer id;private String username;private String password;private List<Course> courses;
}

3.在UserController类中添加add8()请求处理方法。

@RequestMapping("add8")
public User add8(@RequestBody User user) {System.out.println(user);return user;
}

4.使用ApiPost工具测试,需将提交的数据类型设置为application/json格式(GET和POST请求都支持)。

{"id": 1,"username": "tom","password": "123456","courses": [{"id": 1,"courseName": "Java","lecturer": "老师"},{"id": 2,"courseName": "Python","lecturer": "李小红老师"}]
}

5.创建param10.html页面,通过Axios发送请求。

<!DOCTYPE html>
<html><head><meta charset="utf-8" /><title>前后端参数传递</title><script src="https://unpkg.com/vue@next"></script><script src="https://unpkg.com/axios/dist/axios.min.js"></script></head><body><div id="app"></div><script>const app = {data() {return {user: {id: 1,username: 'tom',password: '123456',cat: {id: 1,breed: '蓝白',name: '花花'},courses: [{id: 1,courseName: "Java",lecturer: "老师"},{id: 2,courseName: "Python",lecturer: "张晓东老师"}]}}},mounted() {axios.post('http://localhost:8888/users/add8', this.user).then(response => {console.log('success', response.data);}).catch(error => {console.log('fail', error.data);});}}Vue.createApp(app).mount('#app')</script></body>
</html>

5.Map集合接收参数

1.在UserController类中添加add9()请求处理方法。

@RequestMapping("add9")
public Map<String, Object> add9(@RequestBody Map<String, Object> map) {String username = (String) map.get("username");System.out.println("username : " + username);Map<String, Object> catMap = (Map<String, Object>) map.get("cat");Set<Map.Entry<String, Object>> catSet = catMap.entrySet();for (Map.Entry<String, Object> entry : catSet) {String key = entry.getKey();Object value = entry.getValue();System.out.println(key + " : " + value);}List<Map<String, Object>> courseMapList = (List<Map<String, Object>>) map.get("courses");for (Map<String, Object> courseMap : courseMapList) {Set<Map.Entry<String, Object>> courseSet = courseMap.entrySet();for (Map.Entry<String, Object> entry : courseSet) {String key = entry.getKey();Object value = entry.getValue();System.out.println(key + " : " + value);}}return map;
}

2.使用ApiPost工具测试,需将提交的数据类型设置为application/json格式(GET和POST请求都支持)。

{"id": 1,"username": "tom","password": "123456","courses": [{"id": 1,"courseName": "Java","lecturer": "老师"},{"id": 2,"courseName": "Python","lecturer": "李小红老师"}]
}

3.创建param11.html页面,通过Axios发送请求。

<!DOCTYPE html>
<html><head><meta charset="utf-8" /><title>前后端参数传递</title><script src="https://unpkg.com/vue@next"></script><script src="https://unpkg.com/axios/dist/axios.min.js"></script></head><body><div id="app"></div><script>const app = {data() {return {user: {id: 1,username: 'tom',password: '123456',cat: {id: 1,breed: '蓝白',name: '花花'},courses: [{id: 1,courseName: "Java",lecturer: "老师"},{id: 2,courseName: "Python",lecturer: "张晓东老师"}]}}},mounted() {axios.post('http://localhost:8888/users/add9', this.user).then(response => {console.log('success', response.data);}).catch(error => {console.log('fail', error.data);});}}Vue.createApp(app).mount('#app')</script></body>
</html>

3 总结

本文介绍了在Spring Boot项目中接收前端数据的多种方式。通过创建Spring Boot项目、配置Web依赖和跨域问题,展示了如何使用@RequestParam、@PathVariable、@RequestBody等注解接收不同类型的参数,包括基本类型、数组、复杂对象及嵌套结构。通过实例演示了如何在Controller中处理GET、POST等请求,并通过前端页面发送请求验证后端接收逻辑。

相关文章:

Spring Boot项目接收前端参数的11种方式

大家好&#xff0c;我是。在前后端项目交互中&#xff0c;前端传递的数据可以通过HTTP请求发送到后端&#xff0c; 后端在Spring Boot中如何接收各种复杂的前端数据呢&#xff1f;这篇文章总结了11种在Spring Boot中接收前端数据的方式。 1 搭建项目 1.通过Spring Initializr…...

Springboot项目:使用MockMvc测试get和post接口(含单个和多个请求参数场景)

一、引入MockMvc依赖 使用MockMvc&#xff0c;必须要引入依赖 <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency>二、具体演示…...

OpenAI ChatGPT在心理治疗领域展现超凡同理心,通过图灵测试挑战人类专家

近期&#xff0c;一项关于OpenAI ChatGPT在心理治疗领域的研究更是引起了广泛关注。据报道&#xff0c;ChatGPT已经成功通过了治疗师领域的图灵测试&#xff0c;其表现甚至在某些方面超越了人类治疗师&#xff0c;尤其是在展现同理心方面&#xff0c;这一发现无疑为AI在心理健康…...

【HBase】HBaseJMX 接口监控信息实现钉钉告警

目录 一、JMX 简介 二、JMX监控信息钉钉告警实现 一、JMX 简介 官网&#xff1a;Apache HBase ™ Reference Guide JMX &#xff08;Java管理扩展&#xff09;提供了内置的工具&#xff0c;使您能够监视和管理Java VM。要启用远程系统的监视和管理&#xff0c;需要在启动Java…...

25旅游管理研究生复试面试问题汇总 旅游管理专业知识问题很全! 旅游管理复试全流程攻略 旅游管理考研复试真题汇总

旅游管理复试很难&#xff1f;&#xff01; 别怕&#xff01;经验超丰富的老学姐来给你们出谋划策啦&#xff01; 最近是不是被旅游管理考研复试折磨得够呛&#xff1f;莫慌&#xff01;我这有着丰富复试指导经验的老学姐来帮你们排雷&#xff0c;助力大家顺利上岸&#xff01…...

深入解析C++26 Execution Domain:设计原理与实战应用

一、Domain设计目标与核心价值 Domain是C26执行模型的策略载体&#xff0c;其核心解决两个问题&#xff1a; 执行策略泛化&#xff1a;将线程池、CUDA流等异构调度逻辑抽象为统一接口策略组合安全&#xff1a;通过类型隔离避免不同执行域的策略污染 // Domain类型定义示例&a…...

Linux命令基础

【Linux路径写法】 相对路径与绝对路径&#xff1a; 绝对路径&#xff1a;以根目录为起点&#xff0c;描述路径的一种写法&#xff0c;路径描述以 / 开头 相对路径&#xff1a;以当前目录为起点&#xff0c;描述路径的一种写法&#xff0c;路径描述无需以/开头 特殊路径符&…...

什么是超越编程(逾编程)(元编程?)

超越编程(逾编程)(元编程&#xff1f;)(meta-programming) 目录 1. meta- 的词源 2. 逾编程(meta-programming) 的直实含义 2.1 定义 2.2 说明 3. 翻译成“元编程”应该是一种错误 1. meta- 的词源 这是一个源自希腊语的构词元素&#xff0c;其有三种含义&#xff…...

netcore libreoffice word转pdf中文乱码

一、效果 解决&#xff1a; cd /usr/share/fonts/ mkdir zhFont cd zhFont #windows系统C:\Windows\Fonts 中复制/usr/share/fonts/zhFont sudo apt update sudo apt install xfonts-utils mkfontscale mkfontdir #刷新字体缓存 fc-cache -fv #查看已安装的字体列表 fc-list :…...

【练习】【回溯:组合:一个集合 元素可重复】力扣 39. 组合总和

题目 组合总和 给你一个 无重复元素 的整数数组 candidates 和一个目标整数 target &#xff0c;找出 candidates 中可以使数字和为目标数 target 的 所有 不同组合 &#xff0c;并以列表形式返回。你可以按 任意顺序 返回这些组合。 candidates 中的 同一个 数字可以 无限制重…...

Mac 清理缓存,提高内存空间

步骤 1.打开【访达】 2.菜单栏第五个功能【前往】&#xff0c;点击【个人】 3.【command shift J】显示所有文件&#xff0c;打开【资源库】 4.删除【Containers】和【Caches】文件 Containers 文件夹&#xff1a;用于存储每个应用程序的沙盒数据&#xff0c;确保应用程序…...

数据结构——二叉树经典习题讲解

各位看官早安午安晚安呀 如果您觉得这篇文章对您有帮助的话 欢迎您一键三连&#xff0c;小编尽全力做到更好 欢迎您分享给更多人哦 大家好&#xff0c;我们今天来学习java数据结构的二叉树 递归很重要的一些注意事项&#xff1a; 1&#xff1a;递归你能不能掌握在于&#xff1…...

神经网络八股(三)

1.什么是梯度消失和梯度爆炸 梯度消失是指梯度在反向传播的过程中逐渐变小&#xff0c;最终趋近于零&#xff0c;这会导致靠前层的神经网络层权重参数更新缓慢&#xff0c;甚至不更新&#xff0c;学习不到有用的特征。 梯度爆炸是指梯度在方向传播过程中逐渐变大&#xff0c;…...

堆、优先队列、堆排序

堆&#xff1a; 定义&#xff1a; 必须是一个完全二叉树&#xff08;完全二叉树&#xff1a;完全二叉树只允许最后一行不为满&#xff0c;且最后一行必须从左往右排序&#xff0c;最后一行元素之间不可以有间隔&#xff09; 堆序性&#xff1a; 大根堆&#xff1a;每个父节点…...

vue 学习-vite api.js

/** 整机管理 * */ // 整机分类 列表 export const wholeMachineServersType params > ajaxGet({url: wholeMachine/serverstype/,params}) // 整机分类 新增 export const wholeMachineServersTypeAdd params > ajaxPost({url: wholeMachine/serverstype/,params}) /…...

java练习(35)

ps:题目来自力扣 整数反转 给你一个 32 位的有符号整数 x &#xff0c;返回将 x 中的数字部分反转后的结果。 如果反转后整数超过 32 位的有符号整数的范围 [−231, 231 − 1] &#xff0c;就返回 0。 假设环境不允许存储 64 位整数&#xff08;有符号或无符号&#xff09…...

PW_Balance

目录 1、 PW_Balance 1.1、 getDocumentsTypeID 1.2、 getShouldAmount 1.3、 setOptimalAmount 1.4、 setRemark PW_Balance package com.gx.pojo; public class PW_Balance { private Integer BalanceID; private Integer PaymentID; private Integer ReceptionID…...

【Linux-网络】HTTP的清风与HTTPS的密语

&#x1f3ac; 个人主页&#xff1a;谁在夜里看海. &#x1f4d6; 个人专栏&#xff1a;《C系列》《Linux系列》《算法系列》 ⛰️ 道阻且长&#xff0c;行则将至 目录 &#x1f4da; 引言 &#x1f4da; 一、HTTP &#x1f4d6; 1.概述 &#x1f4d6; 2.URL &#x1f5…...

【前端框架】vue2和vue3的区别详细介绍

Vue 3 作为 Vue 2 的迭代版本&#xff0c;在性能、语法、架构设计等多个维度均有显著的变革与优化。以下详细剖析二者的区别&#xff1a; 响应式系统 Vue 2 实现原理&#xff1a;基于 Object.defineProperty() 方法实现响应式。当一个 Vue 实例创建时&#xff0c;Vue 会遍历…...

CMake管理依赖实战:多仓库的无缝集成

随着软件复杂度的增加&#xff0c;单个项目可能需要依赖多个外部库或模块。这些依赖项可能是来自不同的代码仓库&#xff0c;如ATest和BTest。为了实现高效的依赖管理&#xff0c;CMake提供了多种方式来处理这种多仓库的情况。下面我们将详细介绍几种常见的方法&#xff0c;并通…...

【人工智能】神经网络的优化器optimizer(二):Adagrad自适应学习率优化器

一.自适应梯度算法Adagrad概述 Adagrad&#xff08;Adaptive Gradient Algorithm&#xff09;是一种自适应学习率的优化算法&#xff0c;由Duchi等人在2011年提出。其核心思想是针对不同参数自动调整学习率&#xff0c;适合处理稀疏数据和不同参数梯度差异较大的场景。Adagrad通…...

2024年赣州旅游投资集团社会招聘笔试真

2024年赣州旅游投资集团社会招聘笔试真 题 ( 满 分 1 0 0 分 时 间 1 2 0 分 钟 ) 一、单选题(每题只有一个正确答案,答错、不答或多答均不得分) 1.纪要的特点不包括()。 A.概括重点 B.指导传达 C. 客观纪实 D.有言必录 【答案】: D 2.1864年,()预言了电磁波的存在,并指出…...

Java多线程实现之Callable接口深度解析

Java多线程实现之Callable接口深度解析 一、Callable接口概述1.1 接口定义1.2 与Runnable接口的对比1.3 Future接口与FutureTask类 二、Callable接口的基本使用方法2.1 传统方式实现Callable接口2.2 使用Lambda表达式简化Callable实现2.3 使用FutureTask类执行Callable任务 三、…...

2021-03-15 iview一些问题

1.iview 在使用tree组件时&#xff0c;发现没有set类的方法&#xff0c;只有get&#xff0c;那么要改变tree值&#xff0c;只能遍历treeData&#xff0c;递归修改treeData的checked&#xff0c;发现无法更改&#xff0c;原因在于check模式下&#xff0c;子元素的勾选状态跟父节…...

[10-3]软件I2C读写MPU6050 江协科技学习笔记(16个知识点)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16...

Unsafe Fileupload篇补充-木马的详细教程与木马分享(中国蚁剑方式)

在之前的皮卡丘靶场第九期Unsafe Fileupload篇中我们学习了木马的原理并且学了一个简单的木马文件 本期内容是为了更好的为大家解释木马&#xff08;服务器方面的&#xff09;的原理&#xff0c;连接&#xff0c;以及各种木马及连接工具的分享 文件木马&#xff1a;https://w…...

sipsak:SIP瑞士军刀!全参数详细教程!Kali Linux教程!

简介 sipsak 是一个面向会话初始协议 (SIP) 应用程序开发人员和管理员的小型命令行工具。它可以用于对 SIP 应用程序和设备进行一些简单的测试。 sipsak 是一款 SIP 压力和诊断实用程序。它通过 sip-uri 向服务器发送 SIP 请求&#xff0c;并检查收到的响应。它以以下模式之一…...

(一)单例模式

一、前言 单例模式属于六大创建型模式,即在软件设计过程中,主要关注创建对象的结果,并不关心创建对象的过程及细节。创建型设计模式将类对象的实例化过程进行抽象化接口设计,从而隐藏了类对象的实例是如何被创建的,封装了软件系统使用的具体对象类型。 六大创建型模式包括…...

作为测试我们应该关注redis哪些方面

1、功能测试 数据结构操作&#xff1a;验证字符串、列表、哈希、集合和有序的基本操作是否正确 持久化&#xff1a;测试aof和aof持久化机制&#xff0c;确保数据在开启后正确恢复。 事务&#xff1a;检查事务的原子性和回滚机制。 发布订阅&#xff1a;确保消息正确传递。 2、性…...

SQL Server 触发器调用存储过程实现发送 HTTP 请求

文章目录 需求分析解决第 1 步:前置条件,启用 OLE 自动化方式 1:使用 SQL 实现启用 OLE 自动化方式 2:Sql Server 2005启动OLE自动化方式 3:Sql Server 2008启动OLE自动化第 2 步:创建存储过程第 3 步:创建触发器扩展 - 如何调试?第 1 步:登录 SQL Server 2008第 2 步…...