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

Spring MVC 综合案例

目录

一. 加法计算器

1. 准备工作

2. 约定前后端交互接口

需求分析

接口定义

 3. 服务器端代码

4. 运行测试

二. 用户登录 

1. 准备工作

2. 约定前后端交互接口

需求分析

接口定义

(1) 登录界面接口

 (2) 首页接口

3. 服务器端代码

 4. 运行测试

三. 留言板

1. 准备工作

2. 约定前后端交互接口

需求分析

接口定义

3. 服务器端代码

 四. 图书管理系统

1. 准备工作

2. 约定前后端交互接口

需求分析

接口定义

 3. 服务器端代码

登录页面

图书列表 

创建图书:

返回图书列表:

五. lombook 介绍

 六. 应用分层


一. 加法计算器

1. 准备工作

创建SpringBoot项目, 并引入SpringBoot依赖. 把前端页面的代码放到项目中.

前端代码:

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title>
</head>
<body>
<form action="calc/sum" method="post"><h1>计算器</h1>数字1:<input name="num1" type="text"><br>数字2:<input name="num2" type="text"><br><input type="submit" value=" 点击相加 ">
</form>
</body></html>

2. 约定前后端交互接口

由于现在大多是以 "前后端分离模式" 开发, 前后端代码通常由不同团队进行开发. 所以双方团队在开发之前, 会提前约定好前后端交互方式. 常用 "接口文档" 来描述它. (接口文档 也可以理解为"应用程序的说明书").

  • 需求分析

加法计算器功的能是对两个整数进行相加. 需要客户端提供参与计算的两个数, 服务端返回这两个整数相加的结果.

  • 接口定义

请求路径: clac / sum请求方式: GET / POST接口描述: 计算两个整数相加

请求参数:

响应数据:

Content-Type: text / html响应内容: 计算机计算结果: x 

 3. 服务器端代码

@RestController
@RequestMapping("/calc")
public class CalcController {@RequestMapping("/sum")public String sum(Integer num1, Integer num2) {int sum = num1 + num2;return "<h1>计算机计算结果: "+sum+"</h1>";}
}

4. 运行测试

运行main方法, 启动服务. 

访问服务地址: http://127.0.0.1:8080/calc.html

二. 用户登录 

1. 准备工作

创建SpringBoot项目, 并引入SpringBoot依赖. 把前端页面的代码放到项目中.

  • index.html (登录界面) 代码:
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><title>登录页面</title>
</head><body>
<h1>用户登录</h1>
用户名:<input name="userName" type="text" id="userName"><br>
密码:<input name="password" type="password" id="password"><br>
<input type="button" value="登录" onclick="login()"><script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<script>function login() {//使用ajax进行前后端交互$.ajax({//小括号中是一个对象,对象用大括号括起来type:"post",url:"/user/login",data:{"username":$("#userName").val(),"password":$("#password").val()//通过Id获取值,给后端传递参数},success: function (result) {//参数名任意,用于接收后端返回的参数if (result){location.href = "/index.html"//跳转页面}else {alert("账号或密码有误");//弹窗}}});}</script>
</body></html>
  • login.html (首页) 代码:
<!doctype html>
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport"content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>用户登录首页</title>
</head><body>
登录人: <span id="loginUser"></span><script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<script>$.ajax({type : "get",url : "/user/getLoginUser",success:function (result) {$("#loginUser").text(result);//给loginUser参数赋值为后端返回的result值}})
</script>
</body></html>

2. 约定前后端交互接口

  • 需求分析

(1) 登录页面: 通过账号和密码, 校验输入的账号密码是否正确, 并告知前端.

(2) 首页: 告知前端当前登录用户. 如果当前已有用户登录, 返回登录的账号; 如果没有, 返回空.

  • 接口定义

(1) 登录界面接口

接口定义:

请求路径: /user/login请求方式: POST接口描述: 校验账号密码是否正确.

请求参数: 

响应数据:

Content-Type : text/html
响应内容: 
账号密码正确:true
账号密码错误:false

 (2) 首页接口

接口定义:

请求路径: /user/getLoginuser
请求方式: GET
接口描述: 显示当前登录用户的主页,主页上显示用户名.

请求参数: 无

响应数据: 

Content-Type:text/html
响应内容: 登录的用户名.

3. 服务器端代码

(1) 登录界面接口

@RestController
@RequestMapping("/user")
public class LoginController {@RequestMapping("/login")public boolean login(String userName, String password, HttpSession session) {// 账号或密码为空if (!StringUtils.hasLength(userName) || !StringUtils.hasLength(password)) {return false;}// 校验账号密码是否正确 (这里先写死)if (!"zhangsan".equals(userName) || !"123456".equals(password)) {return false;}//密码验证成功后, 把用户名存储在Session中.session.setAttribute("userName",userName);return true;}//StringUtils.hasLength()是Spring提供的一个方法, 用于判断字符串是否有值.//字符串为 null 或 "" 时, 返回false, 其他情况返回true.
}

(2) 首页接口

@RestController
@RequestMapping("/getLoginUser")
public class getLoginUser {@RequestMapping("/")public String getLoginUser(HttpSession session) {//从Session中获取用户登录信息String userName = (String) session.getAttribute("userName");//如果用户已经登录, 则直接返回用户名if (StringUtils.hasLength(userName)) {return userName;}//否则什么都不返回return "";}
}

 4. 运行测试

验证不成功: 

验证成功:

三. 留言板

1. 准备工作

创建SpringBoot项目, 并引入SpringBoot依赖. 把前端页面的代码放到项目中.

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>留言板</title><style>.container {width: 350px;height: 300px;margin: 0 auto;/* border: 1px black solid; */text-align: center;}.grey {color: grey;}.container .row {width: 350px;height: 40px;display: flex;justify-content: space-between;align-items: center;}.container .row input {width: 260px;height: 30px;}#submit {width: 350px;height: 40px;background-color: orange;color: white;border: none;margin: 10px;border-radius: 5px;font-size: 20px;}</style>
</head><body><div class="container"><h1>留言板</h1><p class="grey">输入后点击提交, 会将信息显示下方空白处</p><div class="row"><span>谁:</span> <input type="text" name="" id="from"></div><div class="row"><span>对谁:</span> <input type="text" name="" id="to"></div><div class="row"><span>说什么:</span> <input type="text" name="" id="say"></div><input type="button" value="提交" id="submit" onclick="submit()"><!-- <div>A 对 B 说: hello</div> --></div><script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.4/jquery.min.js"></script><script>load();//每次在重新加载页面之后,都要从后端的List中调动数据,保证上次添加的数据不会丢失function load(){$.ajax({type: "get",url:"message/getList",success:function (result){for (var message of result){var divE = "<div>"+message.from +"对" + message.to + "说:" + message.say+"</div>";$(".container").append(divE);}}});}function submit(){//1. 获取留言的内容var from = $('#from').val();var to = $('#to').val();var say = $('#say').val();if (from== '' || to == '' || say == '') {return;}$.ajax({type : "post",url : "message/publish",contentType: "application/json",//传递的值是json类型,data就是在向后端传递数据data:JSON.stringify({from : from,to : to,say : say//从前端参数的ID中获取对应的值传递给后端}),//后端返回结果success:function (result) {if (result){//2. 构造节点var divE = "<div>"+from +"对" + to + "说:" + say+"</div>";//3. 把节点添加到页面上$(".container").append(divE);//4. 清空输入框的值$('#from').val("");$('#to').val("");$('#say').val("");}else{alert("提交留言失败")}}});}</script>
</body></html>

2. 约定前后端交互接口

  • 需求分析

后端需要提供两个服务;

(1) 提交留言: 客户输入留言信息之后, 后端要把留言信息保存起来.

(2) 展示留言: 页面展示时, 需要从后端获取到所有的留言信息.

  • 接口定义

1. 获取全部留言

2. 发表新留言

3. 服务器端代码

package com.example.demo;import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;import java.util.ArrayList;
import java.util.List;@RequestMapping("/message")
@RestController
public class MessageWall {public List<MessageInfo> messageInfoList = new ArrayList<>();@RequestMapping("/publish")public Boolean messageController(@RequestBody MessageInfo messageInfo){System.out.println(messageInfo);  //打印日志if (StringUtils.hasLength(messageInfo.from) &&StringUtils.hasLength(messageInfo.to) &&StringUtils.hasLength(messageInfo.say)){messageInfoList.add(messageInfo);return true;  //都有长度,添加成功,返回true}// 否则 添加失败,返回falsereturn false;}@RequestMapping("/getList")public List<MessageInfo> getList(){return messageInfoList;}
}
package com.example.demo;import lombok.Data;@Data
public class MessageInfo {public String from;public String to;public String say;
}

 四. 图书管理系统

1. 准备工作

创建SpringBoot项目, 并引入SpringBoot依赖. 把前端页面的代码放到项目中.

  • 登录页面:
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title><link rel="stylesheet" href="css/bootstrap.min.css"><link rel="stylesheet" href="css/login.css"><script type="text/javascript" src="js/jquery.min.js"></script>
</head><body><div class="container-login"><div class="container-pic"><img src="pic/computer.png" width="350px"></div><div class="login-dialog"><h3>登陆</h3><div class="row"><span>用户名</span><input type="text" name="userName" id="userName" class="form-control"></div><div class="row"><span>密码</span><input type="password" name="password" id="password" class="form-control"></div><div class="row"><button type="button" class="btn btn-info btn-lg" onclick="login()">登录</button></div></div></div><script src="js/jquery.min.js"></script><script>function login() {$.ajax({type:"post",url:"/user/login",data:{name:$("#userName").val(),password:$("#password").val()},success:function (result) {if (result){location.href = "book_list.html";}else{alert("账号或密码错误")}}});}</script>
</body></html>
  • 图书列表:
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>图书列表展示</title><link rel="stylesheet" href="css/bootstrap.min.css"><link rel="stylesheet" href="css/list.css"><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/bootstrap.min.js"></script><script src="js/jq-paginator.js"></script></head><body><div class="bookContainer"><h2>图书列表展示</h2><div class="navbar-justify-between"><div><button class="btn btn-outline-info" type="button" onclick="location.href='book_add.html'">添加图书</button><button class="btn btn-outline-info" type="button" onclick="batchDelete()">批量删除</button></div></div><table><thead><tr><td>选择</td><td class="width100">图书ID</td><td>书名</td><td>作者</td><td>数量</td><td>定价</td><td>出版社</td><td>状态</td><td class="width200">操作</td></tr></thead><tbody></tbody></table><div class="demo"><ul id="pageContainer" class="pagination justify-content-center"></ul></div><script>getBookList();function getBookList() {$.ajax({type: "get",url: "/book/getList",success: function (result) {console.log(result);if (result != null) {var finalHtml = "";//构造字符串for (var book of result) {finalHtml += '<tr>';finalHtml += '<td><input type="checkbox" name="selectBook" value="' + book.id + '" id="selectBook" class="book-select"></td>';finalHtml += '<td>' + book.id + '</td>';finalHtml += '<td>' + book.bookName + '</td>';finalHtml += '<td>' + book.author + '</td>';finalHtml += '<td>' + book.count + '</td>';finalHtml += '<td>' + book.price + '</td>';finalHtml += '<td>' + book.publish + '</td>';finalHtml += '<td>' + book.statusCN + '</td>';finalHtml += '<td><div class="op">';finalHtml += '<a href="book_update.html?bookId=' + book.id + '">修改</a>';finalHtml += '<a href="javascript:void(0)"οnclick="deleteBook(' + book.id + ')">删除</a>';finalHtml += '</div></td>';finalHtml += "</tr>";}$("tbody").html(finalHtml);}}});}//翻页信息$("#pageContainer").jqPaginator({totalCounts: 100, //总记录数pageSize: 10,    //每页的个数visiblePages: 5, //可视页数currentPage: 1,  //当前页码first: '<li class="page-item"><a class="page-link">首页</a></li>',prev: '<li class="page-item"><a class="page-link" href="javascript:void(0);">上一页<\/a><\/li>',next: '<li class="page-item"><a class="page-link" href="javascript:void(0);">下一页<\/a><\/li>',last: '<li class="page-item"><a class="page-link" href="javascript:void(0);">最后一页<\/a><\/li>',page: '<li class="page-item"><a class="page-link" href="javascript:void(0);">{{page}}<\/a><\/li>',//页面初始化和页码点击时都会执行onPageChange: function (page, type) {console.log("第"+page+"页, 类型:"+type);}});function deleteBook(id) {var isDelete = confirm("确认删除?");if (isDelete) {//删除图书alert("删除成功");}}function batchDelete() {var isDelete = confirm("确认批量删除?");if (isDelete) {//获取复选框的idvar ids = [];$("input:checkbox[name='selectBook']:checked").each(function () {ids.push($(this).val());});console.log(ids);alert("批量删除成功");}}</script></div>
</body></html>

2. 约定前后端交互接口

  • 需求分析

登录: 用户输入账号和密码完成登录功能.

列表: 展示图书

  • 接口定义

登录接口:

[URL]
POST /user/login
[请求参数]
name=admin&password=admin
[响应]
true //账号密码验证成功
false//账号密码验证失败

列表:

[URL]
POST /book/getList
[请求参数]
⽆
[响应]
返回图书列表
[{"id": 1,"bookName": "活着","author": "余华","count": 270,"price": 20,"publish": "北京⽂艺出版社","status": 1,"statusCN": "可借阅"},...

属性说明: 

 3. 服务器端代码

  • 登录页面

package com.jrj.library;import jakarta.servlet.http.HttpSession;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;@RequestMapping("/user")
@RestController
public class Login {@RequestMapping("/login")public Boolean login(String name, String password, HttpSession session){if (!StringUtils.hasLength(name) || !StringUtils.hasLength(password)){return false;}if ("zhangsan".equals(name) && "123456".equals(password)){session.setAttribute("userName",name);return true;}return false;}
}
  • 图书列表 

创建图书:
package com.jrj.library;import lombok.Data;@Data
public class BookInfo {//构造一本书所有的属性public Integer id;public String bookName;public String author;public Integer count;public Integer price;public String publish;public Integer status;//1-可借阅,2-不可借阅public String statusCN;
}
返回图书列表:
package com.jrj.library;import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;import java.util.ArrayList;
import java.util.List;
import java.util.Random;@RequestMapping("/book")
@RestController
public class BookController {@RequestMapping("/getList")public List<BookInfo> getList(){List<BookInfo> list = mockData();for (BookInfo bookInfo:list){if (bookInfo.status == 1){bookInfo.setStatusCN("可借阅");}else{bookInfo.setStatusCN("不可借阅");}}return list;}//模拟数据private List<BookInfo> mockData(){List<BookInfo> list2 = new ArrayList<>();for (int i = 0; i < 5; i++) {BookInfo bookInfo = new BookInfo();bookInfo.setId(i);bookInfo.setBookName("Java编程思想"+i);bookInfo.setCount(1);bookInfo.setPublish("机械工业出版社");bookInfo.setPrice(new Random().nextInt(100));bookInfo.setAuthor("高斯林");bookInfo.setStatus(1);list2.add(bookInfo);}return list2;}
}

五. lombook 介绍

lombook是一个Java工具库, 通过添加注解的方式, 来简化Java开发.

使用方法:

也可直接使用 @Data注解, 只不过 @Data注解 比较粗暴: 

@Data =

@Getter+@Setter+@ToString+@NoArgsConstructor +@RequiredArgsConstructor  

 六. 应用分层

为了不使我们的代码看起来比较杂乱, 我们使用应用分层来对代码进行分层管理.

Spring项目常见的三层应用分层:

Controller (接口层) : 负责与外部做交互.

Service (逻辑层) : 负责做逻辑处理.

Mapper / Dao (持久层) : 负责从数据库拿数据 (相当于数据库的客户端).

还有最底层的数据库 (DB) : 使用MySQL或Oracle (不在三层分层中).

MVC和三层架构的关系:

软件设计原则: 高内聚+低耦合

相关文章:

Spring MVC 综合案例

目录 一. 加法计算器 1. 准备工作 2. 约定前后端交互接口 需求分析 接口定义 3. 服务器端代码 4. 运行测试 二. 用户登录 1. 准备工作 2. 约定前后端交互接口 需求分析 接口定义 (1) 登录界面接口 (2) 首页接口 3. 服务器端代码 4. 运行测试 三. 留言板 1. 准备…...

Spring Boot多环境配置实践指南

在开发Spring Boot应用时&#xff0c;我们常常需要根据不同的运行环境&#xff08;如开发环境、测试环境和生产环境&#xff09;来配置不同的参数。Spring Boot提供了非常灵活的多环境配置机制&#xff0c;通过使用profile-specific properties文件&#xff0c;我们可以轻松地管…...

微信小程序中实现进入页面时数字跳动效果(自定义animate-numbers组件)

微信小程序中实现进入页面时数字跳动效果 1. 组件定义,新建animate-numbers组件1.1 index.js1.2 wxml1.3 wxss 2. 使用组件 1. 组件定义,新建animate-numbers组件 1.1 index.js // components/animate-numbers/index.js Component({properties: {number: {type: Number,value…...

【huawei】云计算的备份和容灾

目录 1 备份和容灾 2 灾备的作用&#xff1f; ① 备份的作用 ② 容灾的作用 3 灾备的衡量指标 ① 数据恢复时间点&#xff08;RPO&#xff0c;Recoyery Point Objective&#xff09; ② 应用恢复时间&#xff08;RTO&#xff0c;Recoyery Time Objective&#xff09; 4…...

Vue.js组件开发-实现下载时暂停恢复下载

在 Vue 中实现下载时暂停和恢复功能&#xff0c;通常可以借助 XMLHttpRequest 对象来控制下载过程。XMLHttpRequest 允许在下载过程中暂停和继续请求。 实现步骤 创建 Vue 组件&#xff1a;创建一个 Vue 组件&#xff0c;包含下载、暂停和恢复按钮。初始化 XMLHttpRequest 对…...

TCP是怎么判断丢包的?

丢包在复杂的网络环境中&#xff0c;是一种常见的现象。 TCP&#xff08;传输控制协议&#xff09;作为一种可靠传输协议&#xff0c;内置了多种机制来检测和处理丢包现象&#xff0c;从而保证数据的完整性和传输的可靠性。本文将介绍TCP判断丢包的原理和机制。 一、TCP可靠传…...

python爬虫入门(一) - requests库与re库,一个简单的爬虫程序

目录 web请求与requests库 1. web请求 1.1 客户端渲染与服务端渲染 1.2 抓包 1.3 HTTP状态代码 2. requests库 2.1 requests模块的下载 2.2 发送请求头与请求参数 2.3 GET请求与POST请求 GET请求的例子&#xff1a; POST请求的例子&#xff1a; 3. 案例&#xff1a;…...

2025年数学建模美赛 A题分析(3)楼梯使用方向偏好模型

2025年数学建模美赛 A题分析&#xff08;1&#xff09;Testing Time: The Constant Wear On Stairs 2025年数学建模美赛 A题分析&#xff08;2&#xff09;楼梯磨损分析模型 2025年数学建模美赛 A题分析&#xff08;3&#xff09;楼梯使用方向偏好模型 2025年数学建模美赛 A题分…...

复古壁纸中棕色系和米色系哪个更受欢迎?

根据最新的搜索结果&#xff0c;我们可以看到棕色系和米色系在复古壁纸设计中都非常受欢迎。以下是对这两种颜色系受欢迎程度的分析&#xff1a; 棕色系 受欢迎程度&#xff1a;棕色系在复古壁纸中非常受欢迎&#xff0c;因为它能够营造出温暖、质朴和自然的氛围。棕色系的壁纸…...

编译安装PaddleClas@openKylin(失败,安装好后报错缺scikit-learn)

编译安装 前置需求&#xff1a; 手工安装swig和faiss-cpu pip install swig pip install faiss-cpu 小技巧&#xff0c;pip编译安装的时候&#xff0c;可以加上--jobs64来多核编译。 注意先升级pip版本&#xff1a;pip install pip -U pip3 install faiss-cpu --config-s…...

t113_can增加驱动

1 基于太极派的SDK添加 //设备树添加can0: can2504000 {compatible "allwinner,sun20i-d1-can";reg <0x0 0x02504000 0x0 0x400>;interrupts <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>;clocks <&ccu CLK_BUS_CAN0>;resets <&ccu RST_BUS_…...

达梦数据库建用户,键库脚本

-- 1.创建表空间 CREATE TABLESPACE "表空间名称" DATAFILE /dmdata/data/DAMENG/表空间名称.DBF SIZE 512 AUTOEXTEND ON NEXT 512 MAXSIZE UNLIMITED; -- 2.创建用户 CREATE USER "表空间名称" IDENTIFIED BY "表空间名称" HASH WITH SHA512 S…...

上海亚商投顾:沪指冲高回落 大金融板块全天强势 上海亚商投

上海亚商投顾前言&#xff1a;无惧大盘涨跌&#xff0c;解密龙虎榜资金&#xff0c;跟踪一线游资和机构资金动向&#xff0c;识别短期热点和强势个股。 一&#xff0e;市场情绪 市场全天冲高回落&#xff0c;深成指、创业板指午后翻绿。大金融板块全天强势&#xff0c;天茂集团…...

MySQL 的索引类型【图文并茂】

基本分类 文本生成MindMap:https://app.pollyoyo.com/planttext <style> mindmapDiagram {node {BackgroundColor yellow}:depth(0) {BackGroundColor SkyBlue}:depth(1) {BackGroundColor lightGreen} } </style> * MySQL 索引** 数据结构角度 *** B树索引*** 哈…...

天聚地合:引领API数据流通服务,助力数字经济发展

天聚地合&#xff1a;引领API数据流通服务,助力数字经济发展 爱企猫01月24日消息&#xff1a;天聚地合&#xff08;苏州&#xff09;科技股份有限公司,成立于2010年,总部位于苏州,是一家综合性API数据流通服务商。公司旗下品牌‘聚合数据’已开发超过790个API,服务百万企业级客…...

【反悔堆】【hard】力扣871. 最低加油次数

汽车从起点出发驶向目的地&#xff0c;该目的地位于出发位置东面 target 英里处。 沿途有加油站&#xff0c;用数组 stations 表示。其中 stations[i] [positioni, fueli] 表示第 i 个加油站位于出发位置东面 positioni 英里处&#xff0c;并且有 fueli 升汽油。 假设汽车油…...

electron typescript运行并设置eslint检测

目录 一、初始化package.json 二、安装依赖 1、安装electron 2、安装typescript依赖 3、安装eslint 三、项目结构 四、配置启动项 一、初始化package.json 我的&#xff1a;这里的"main"没太大影响&#xff0c;看后面的步骤。 {"name": "xlo…...

服务器上安装Nginx详细步骤

第一步&#xff1a;上传nginx压缩包到指定目录。 第二步&#xff1a;解压nginx压缩包。 第三步&#xff1a;配置编译nginx 配置编译方法&#xff1a; ./configure 配置编译后结果信息&#xff1a; 第四步&#xff1a;编译nginx 在nginx源文件目录中直接运行make命令 第五步&…...

Timeout or no response waiting for NATS JetStream server

当使用jetStream 出现"Timeout or no response waiting for NATS JetStream server" 错误的时候要注意后面的“no response”&#xff0c;尤其是开发测试&#xff0c;要去check server 是否启动了 jet stream。 [20112] 2025/01/24 08:27:42.738396 [INF] _ ___…...

5.2 软件需求分析

文章目录 需求分析的意义软件需求的组成需求分析的5个方面需求分析方法 需求分析的意义 需求分析解决软件“做什么”的问题。由于开发人员比较熟悉计算机而不熟悉领域业务&#xff0c;用户比较熟悉领域业务而不熟悉计算机&#xff0c;双方需要通过交流&#xff0c;制定出完整、…...

React hook之useRef

React useRef 详解 useRef 是 React 提供的一个 Hook&#xff0c;用于在函数组件中创建可变的引用对象。它在 React 开发中有多种重要用途&#xff0c;下面我将全面详细地介绍它的特性和用法。 基本概念 1. 创建 ref const refContainer useRef(initialValue);initialValu…...

Debian系统简介

目录 Debian系统介绍 Debian版本介绍 Debian软件源介绍 软件包管理工具dpkg dpkg核心指令详解 安装软件包 卸载软件包 查询软件包状态 验证软件包完整性 手动处理依赖关系 dpkg vs apt Debian系统介绍 Debian 和 Ubuntu 都是基于 Debian内核 的 Linux 发行版&#xff…...

Qt Widget类解析与代码注释

#include "widget.h" #include "ui_widget.h"Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget) {ui->setupUi(this); }Widget::~Widget() {delete ui; }//解释这串代码&#xff0c;写上注释 当然可以&#xff01;这段代码是 Qt …...

条件运算符

C中的三目运算符&#xff08;也称条件运算符&#xff0c;英文&#xff1a;ternary operator&#xff09;是一种简洁的条件选择语句&#xff0c;语法如下&#xff1a; 条件表达式 ? 表达式1 : 表达式2• 如果“条件表达式”为true&#xff0c;则整个表达式的结果为“表达式1”…...

使用 SymPy 进行向量和矩阵的高级操作

在科学计算和工程领域&#xff0c;向量和矩阵操作是解决问题的核心技能之一。Python 的 SymPy 库提供了强大的符号计算功能&#xff0c;能够高效地处理向量和矩阵的各种操作。本文将深入探讨如何使用 SymPy 进行向量和矩阵的创建、合并以及维度拓展等操作&#xff0c;并通过具体…...

初探Service服务发现机制

1.Service简介 Service是将运行在一组Pod上的应用程序发布为网络服务的抽象方法。 主要功能&#xff1a;服务发现和负载均衡。 Service类型的包括ClusterIP类型、NodePort类型、LoadBalancer类型、ExternalName类型 2.Endpoints简介 Endpoints是一种Kubernetes资源&#xf…...

rknn toolkit2搭建和推理

安装Miniconda Miniconda - Anaconda Miniconda 选择一个 新的 版本 &#xff0c;不用和RKNN的python版本保持一致 使用 ./xxx.sh进行安装 下面配置一下载源 # 清华大学源&#xff08;最常用&#xff09; conda config --add channels https://mirrors.tuna.tsinghua.edu.cn…...

MyBatis-Plus 常用条件构造方法

1.常用条件方法 方法 说明eq等于 ne不等于 <>gt大于 >ge大于等于 >lt小于 <le小于等于 <betweenBETWEEN 值1 AND 值2notBetweenNOT BETWEEN 值1 AND 值2likeLIKE %值%notLikeNOT LIKE %值%likeLeftLIKE %值likeRightLIKE 值%isNull字段 IS NULLisNotNull字段…...

联邦学习带宽资源分配

带宽资源分配是指在网络中如何合理分配有限的带宽资源&#xff0c;以满足各个通信任务和用户的需求&#xff0c;尤其是在多用户共享带宽的情况下&#xff0c;如何确保各个设备或用户的通信需求得到高效且公平的满足。带宽是网络中的一个重要资源&#xff0c;通常指的是单位时间…...

【R语言编程——数据调用】

这里写自定义目录标题 可用库及数据集外部数据导入方法查看数据集信息 在R语言中&#xff0c;有多个库支持调用内置数据集或外部数据&#xff0c;包括studentdata等教学或示例数据集。以下是常见的库和方法&#xff1a; 可用库及数据集 openintro库 该库包含多个教学数据集&a…...