SpringBoot项目实战(初级)
目录
一、数据库搭建
二、代码开发
1.pom.xml
2.thymeleaf模块处理的配置类
3.application配置文件
4.配置(在启动类中)
5.编写数据层
②编写dao层
③编写service层
接口
实现类
注意
补充(注入的3个注解)
1.@AutoWired(类型注入)
2.@Qualifier(名称注入)
3.@Qualifier
④编写controller层
前端页面
1.add.html
2.header.html
3.index.html
4.login.html
5.main.html
7.update.html
css
1.header.css
2.login.css
4.style.css
controller代码
⑤编写拦截类
三、测试
搭建一个简单的登录拦截页面。
首先,先来看一下最终的目录结构:

一、数据库搭建
这里演示案例用的是MySQL数据库,并且数据库名称和表格结构如下所示 :
可以通过手动图形点击的方式实现;或是打开一个查询页面,然后输入下面的SQL语句:
-- 创建数据库(如果尚未存在)
CREATE DATABASE IF NOT EXISTS boot_demo;
-- 使用数据库
USE boot_demo;
-- 创建表格
CREATE TABLE IF NOT EXISTS txperson (pid INT PRIMARY KEY,username VARCHAR(255) NOT NULL,password VARCHAR(255) NOT NULL,p_addr INT,pname VARCHAR(255),gender INT,birth DATE
);
二、代码开发
首先创建一个springboot项目,详细步骤参见下面这篇文章(任选里面一种即可):
SpringBoot(一)--搭建架构5种方法_springboot框架搭建-CSDN博客文章浏览阅读2.2k次,点赞19次,收藏39次。Spring Boot 是基于 Spring 框架,以约定优于配置、自动配置为核心,可快速构建独立运行的应用,为微服务等开发提供便利的开发框架。前面已经对SSM(Spring,SpringMVC,MyBatis)每个框架做了讲解,SpringBoot就是基于这个框架一个更简单、更有利于开发。_springboot框架搭建
https://blog.csdn.net/m0_74977981/article/details/146139845?spm=1001.2014.3001.5502
1.pom.xml
首先导入项目所需要的依赖;这是在搭建一个项目后开始写代码之前的第一步骤。
怎么在maven中央仓库找到自己需要的代码和版本参见下面这篇文章的这一部分:
SSM项目的基本目录结构_ssm框架项目的工程目录-CSDN博客文章浏览阅读662次,点赞19次,收藏21次。一个完整的SSM(Spring+SpringMVC+MyBatis)项目理应包含以下几个目录结构:上面是一个普通的maven项目。_ssm框架项目的工程目录https://blog.csdn.net/m0_74977981/article/details/145968984?spm=1001.2014.3001.5502#t17这里我的jdk版本的1.8即Java8;springboot框架是2.7.0版本,老规矩我会将演示案例的pom.xml文件内容展示出来:
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.7.0</version><relativePath/> <!-- lookup parent from repository --></parent><groupId>cn.tx.springboot</groupId><artifactId>tx_sys</artifactId><version>0.0.1-SNAPSHOT</version><name>tx_sys</name><description>Demo project for Spring Boot</description><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-devtools</artifactId><optional>true</optional></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-thymeleaf</artifactId></dependency><!--导入jquery--><dependency><groupId>org.webjars</groupId><artifactId>jquery</artifactId><version>3.3.1</version></dependency><dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId><version>1.3.1</version></dependency><dependency><groupId>com.alibaba</groupId><artifactId>druid</artifactId><version>1.0.9</version></dependency><dependency><groupId>log4j</groupId><artifactId>log4j</artifactId><version>1.2.17</version></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><scope>runtime</scope></dependency><dependency><groupId>net.sourceforge.nekohtml</groupId><artifactId>nekohtml</artifactId><version>1.9.22</version></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build></project>
2.thymeleaf模块处理的配置类
package cn.tx.springboot.srcConfig;import cn.tx.springboot.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;import java.util.ArrayList;
import java.util.List;/*** Spring MVC 配置类* 用于配置视图控制器和拦截器*/
@Configuration
public class TxMvcConfig implements WebMvcConfigurer {/*** 添加视图控制器* 用于直接将请求映射到视图页面,而不需要通过Controller类处理** @param registry 视图控制器注册器*/@Overridepublic void addViewControllers(ViewControllerRegistry registry) {// 将 /index 请求映射到 index 视图页面registry.addViewController("/index").setViewName("index");// 将 /menu 请求映射到 menu 视图页面registry.addViewController("/menu").setViewName("menu");// 将 /header 请求映射到 header 视图页面registry.addViewController("/header").setViewName("header");// 将 /login 请求映射到 login 视图页面registry.addViewController("/login").setViewName("login");// 将 /add 请求映射到 add 视图页面registry.addViewController("/add").setViewName("add");}/*** 添加拦截器* 配置一个登录拦截器,用于拦截请求并执行登录验证逻辑** @param registry 拦截器注册器*/@Overridepublic void addInterceptors(InterceptorRegistry registry) {// 创建一个排除路径的列表List<String> excludePatterns = new ArrayList<>();// 添加不需要拦截的路径excludePatterns.add("/css/**"); // 排除所有以 /css/ 开头的静态资源路径excludePatterns.add("/images/**"); // 排除所有以 /images/ 开头的静态资源路径excludePatterns.add("/webjars/**"); // 排除所有以 /webjars/ 开头的路径excludePatterns.add("/login"); // 排除登录页面路径excludePatterns.add("/toLogin"); // 排除跳转到登录页面的路径// 注册登录拦截器// 拦截所有请求路径,但排除上述定义的路径registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/**") // 拦截所有路径.excludePathPatterns(excludePatterns); // 排除指定路径}
}
这段代码中使用了addViewController
方法,它是ViewControllerRegistry
接口提供的一个方法,用于将请求路径映射到视图名称(这么用主要是因为可以在一个方法中实现多条路径的映射)。具体语法如下:
registry.addViewController("/path").setViewName("viewName");
3.application配置文件
接着在配置文件配置好链接数据库的信息:
spring:datasource:username: rootpassword: 2020url: jdbc:mysql://localhost:3306/boot_demo?serverTimezone=GMT%2B8driver-class-name: com.mysql.cj.jdbc.Drivertype: com.alibaba.druid.pool.DruidDataSourceinitialSize: 5minIdle: 5maxActive: 20maxWait: 60000timeBetweenEvictionRunsMillis: 60000minEvictableIdleTimeMillis: 300000validationQuery: SELECT 1 FROM DUALtestWhileIdle: truetestOnBorrow: falsetestOnReturn: falsepoolPreparedStatements: truefilters: stat,wall,log4jmaxPoolPreparedStatementPerConnectionSize: 20useGlobalDataSourceStat: trueconnectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=500mvc:format:date: yyyy-MM-dd
这里面的配置项解析参见:SpringBoot 第三课(Ⅰ) 数据层开发-CSDN博客
除此之外,这里额外注意一点:
![]()
注意框起来的.cj. 在配置驱动时会遇见这个问题,有的加cj,有的不加cj,但是在某些时刻好像都是正确的,这就涉及到一些版本问题了:
MySQL现在三个版本:5.6(低版本);5.7(低版本);8.0(高版本)
但是能不能用cj,取决于jar包,并不是MySQL的版本决定的。
如果你需要使用
com.mysql.cj.jdbc.Driver
,那么你需要引入 MySQL Connector/J 8.x 的依赖;同理如果是引入5.x的依赖,那么在配置文件这里就不用加cj。
4.配置(在启动类中)
可以选择加一个config包,里面写配置类;也可以写在springboot的项目启动类中,在这里我采用将配置写进启动类中(因为我这个演示的项目逻辑比较简单,一般情况下不建议这么做):
package cn.tx.springboot;import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.support.http.StatViewServlet;
import com.alibaba.druid.support.http.WebStatFilter;
import org.mybatis.spring.annotation.MapperScan;
import org.mybatis.spring.boot.autoconfigure.ConfigurationCustomizer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;@MapperScan("cn.tx.springboot.dao") //在驱动类标注好mapper的文件包,这样就不用在每个dao接口文件中标注@Mapper了
@SpringBootApplication
public class TxSysApplication {public static void main(String[] args) {SpringApplication.run(TxSysApplication.class, args);}@ConfigurationProperties(prefix = "spring.datasource")@Beanpublic DruidDataSource getDruidDataSource(){return new DruidDataSource();}@Beanpublic ServletRegistrationBean statViewServlet(){ServletRegistrationBean bean = new ServletRegistrationBean(new StatViewServlet(),"/druid/*");Map<String,String> initParams = new HashMap<>();initParams.put("loginUsername","root");initParams.put("loginPassword","root");initParams.put("allow","");//默认就是允许所有访问initParams.put("deny","192.168.15.21");bean.setInitParameters(initParams);return bean;}//2、配置一个web监控的filter@Beanpublic FilterRegistrationBean webStatFilter(){FilterRegistrationBean bean;bean = new FilterRegistrationBean();bean.setFilter(new WebStatFilter());Map<String,String> initParams = new HashMap<>();initParams.put("exclusions","*.js,*.css,/druid/*");bean.setInitParameters(initParams);bean.setUrlPatterns(Arrays.asList("/*"));return bean;}@Beanpublic ConfigurationCustomizer getCustomizer(){return new ConfigurationCustomizer() {@Overridepublic void customize(org.apache.ibatis.session.Configuration configuration) {configuration.setMapUnderscoreToCamelCase(true);}};}
}
5.编写数据层
①编写实体类
package cn.tx.springboot.model;import java.util.Date;public class TxPerson {private int pid;private String username;private String password;private String pAddr;private String pname;private int gender;private Date birth;public TxPerson() {}public TxPerson(int pid, String username, String password, String addr, int gender, Date birth) {this.pid = pid;this.username = username;this.password = password;this.pAddr = pAddr;this.gender = gender;this.birth = birth;}public int getPid() {return pid;}public void setPid(int pid) {this.pid = pid;}public String getPname() {return pname;}public void setPname(String pname) {this.pname = pname;}public String getUsername() {return username;}public void setUsername(String username) {this.username = username;}public String getPassword() {return password;}public void setPassword(String password) {this.password = password;}public String getpAddr() {return pAddr;}public void setpAddr(String pAddr) {this.pAddr = pAddr;}public int getGender() {return gender;}public void setGender(int gender) {this.gender = gender;}public Date getBirth() {return birth;}public void setBirth(Date birth) {this.birth = birth;}@Overridepublic String toString() {return "TxPerson{" +"pid=" + pid +", username='" + username + '\'' +", password='" + password + '\'' +", pAddr='" + pAddr + '\'' +", pname='" + pname + '\'' +", gender=" + gender +", birth=" + birth +'}';}
}
②编写dao层
这里选用SQL全注解的形式编写dao接口文件:
package cn.tx.springboot.dao;import cn.tx.springboot.model.TxPerson;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;import java.util.List;
import java.util.Map;//@Mapper
/*** IDEA在注入处报错(报红),因为找不到注入的对象,因为类是动态创建的,但是程序可以正确的执行。* 为了避免报错,可以在被注入dao接口上添加 @Repository 注解* */
@Repositorypublic interface PersonDao {@Select("select * from txperson")public List<TxPerson> select();@Select("select * from txperson where pid=#{pid}")public TxPerson getPersonById(int pid);@Update("update txperson set " +"username=#{username}," +"password=#{password}," +"pname=#{pname}," +"p_addr=#{pAddr}," +"gender=#{gender}," +"birth=#{birth} " +"where pid=#{pid}")public void updatePerson(TxPerson txPerson);@Options(useGeneratedKeys = true,keyProperty = "pid")@Insert("insert into txperson(pid, username,password,pname, p_addr,gender, birth)" +" values(#{pid}, #{username},#{password},#{pname}, #{pAddr},#{gender}, #{birth})")public void insert(TxPerson P);@Delete("delete from txperson where pid=#{pid}")public int delete(int pid);@Select("select * from txperson where username=#{username} and password=#{password}")public TxPerson getPersonUsepass(Map map);
}
可以看见在这个文件中,我将@Mapper注释掉了,但是项目启动后仍旧能够正常运行起来,这是因为我在启动类中标注了扫描路径。

注:其实可以发现,这么编写相较于Spring框架的编写格式来说,省去了编写Mapper.xml文件(因为将sql语句直接赋予给dao接口了),这么编写大大节省的代码量。
但是这么写还是不够精简,后面为了方便项目开发,将引进MyBatisPlus技术,实现省略简单SQL语句的编写。
③编写service层
接口
package cn.tx.springboot.service;import cn.tx.springboot.model.TxPerson;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;import java.util.List;
import java.util.Map;@Transactional
public interface PersonService {public List<TxPerson> select();//修改首先通过id获取要修改的数据public TxPerson getPersonById(int pid);//在通过修改方法修改public void updatePerson(TxPerson txPerson);public void insert(TxPerson P);public int delete(int pid);public TxPerson getPersonUsepass(Map map);
}
实现类
在service层的实现类中,一个方法中甚至可以调用多个dao的接口方法来实现一个业务逻辑方法(当然我这里展示的逻辑都比较简单)
package cn.tx.springboot.service.impl;import cn.tx.springboot.dao.PersonDao;
import cn.tx.springboot.model.TxPerson;
import cn.tx.springboot.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import java.util.List;
import java.util.Map;@Service
public class PersonServiceImpl implements PersonService {@Autowiredprivate PersonDao personDao;@Overridepublic List<TxPerson> select() {List<TxPerson> list = personDao.select();return list;}@Overridepublic TxPerson getPersonById(int pid) {return personDao.getPersonById(pid);}@Overridepublic void updatePerson(TxPerson txPerson) {personDao.updatePerson(txPerson);}@Overridepublic void insert(TxPerson P) {personDao.insert(P);}@Overridepublic int delete(int pid) {return personDao.delete(pid);}@Overridepublic TxPerson getPersonUsepass(Map map) {TxPerson txPerson = personDao.getPersonUsepass(map);return txPerson;}
}
注意
controller层要注入service层(当然service的实现类注入dao“接口”同理;---@Autowired是进行注入的注释)
但是显而易见接口是不能被注入的,这里被注入的其实是实现这个接口的实体类。
![]()
注入(图Ⅰ) 补充(注入的3个注解)
提到这里就不得不多说一嘴有关实现注入的3个注解:
1.@AutoWired(类型注入)
什么叫类型注入?顾名思义,就是只用填写类型,不用明确指出名字。前面已经提了,接口是不能被注入的,本质上注入的都是实现类。
在Ⅰ图中我这么直接写是可以的,这是因为我的实现类层中只有一个实现类(参见图Ⅱ)
![]()
图Ⅱ 一旦我在impl中再创建一个实现PersonService接口的实现类,图Ⅰ中的部分就将报错,这是因为同类型(即同样是实现PersonService接口的情况)下,有两个实现类了,导致@AutoWired注解注入混乱,因此报错。
2.@Qualifier(名称注入)
这个就很容易理解了,在使用这个注解时表明要注入的实体类的名称,而不是只标注它们实现接口的名称这么泛泛。
上面这两种注入方式(@AutoWired和@Qualifier)都是由Spring框架提供的,其中@AutoWired用到最多。
3.@Qualifier
可以按照名称再按照类型,并且是Jdk封装的,利用反射机制(不建议使用这个注解,主要还是上面那两种居多。)
④编写controller层
在编写controller之前,先将前端页面信息展示:
首先目录一共有这么几个页面:

前端页面
1.add.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
body {font-family: Arial, Helvetica, sans-serif; font-size:12px; text-align:center;}
a { text-decoration: none;}
#all {widht: 100%; text-align:center; margin:auto;}
main {width: 96%; line-height: 1.8; margin:auto; border:1px #ccc dashed; text-align: left; text-indent: 2em;}
.mt{width: 1000px;border:1px solid #aca7a7 ;border-collapse: collapse;
}
.mt td{border: 1px solid #aca7a7;
}</style>
</head><body>
<div id="all"><form th:action="@{/insert}" method="post"><table class="mt"><tr><td>用户名</td><td><input type="text" name="username"/></td><td>密码</td><td><input type="text" name="password"/></td><td>姓名</td><td><input type="text" name="pname"/></td><td>地址</td><td><input type="text" name="pAddr"/></td><td>性别</td><td><select name="gender"><option value="1">男</option><option value="2">女</option></select></td><td>生日</td><td><input type="text" name="birth"/></td><td><input type="submit" value="提交"/></td></tr></table></form>
</div>
</body>
</html>
2.header.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Admin Header</title><link href="css/header.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" language="javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
var oplist = new Array('about', 'user', 'news', 'mars', 'jielong', 'box', 'school', 'config', 'other');
$(document).ready(function() {$('#nav').find("a").click(function() {var id = $(this).attr('id');$.each(oplist, function(i, n) {$('#'+n).attr('class', 'inactive');});$(this).parents("li").attr('class', 'active');});
});
</script>
</head><body>
<div id="all"><div id="banner"><h1>Springboot实训</h1></div><div id="nav"><ul><li class="inactive" id="other"><a href="menu.html" target="menu">管理操作</a></li><li class="inactive" id="about"><a href="menu.html" target="menu">管理操作</a></li><li class="inactive" id="user"><a href="menu.html" target="menu">管理操作</a></li><li class="inactive" id="news"><a href="menu.html" target="menu">管理操作</a></li><li class="inactive" id="mars"><a href="menu.html" target="menu">管理操作</a></li><li class="inactive" id="jielong"><a href="menu.html" target="menu">管理操作</a></li><li class="inactive" id="box"><a href="menu.html" target="menu">管理操作</a></li><li class="inactive" id="school"><a href="menu.html" target="menu">火柴学堂</a></li><li class="active" id="config"><a href="menu.html" target="menu">站点设置</a></li></ul></div><div id="main"><div id="welcome"><span th:if="${session.user != null}" th:text="${session.user.username}+'欢迎你回来!'"></span><a target="_top" th:if="${session.user == null}" th:href="@{/login}">请登录</a><img src="images/clock.gif" /> 学习是最好的投资</div><div id="adminop"><ul><li><a href="#">站点首页</a></li><li><a href="javascript:parent.location.reload();">管理首页</a></li><li><a href="javascript:parent.location.reload();">退出管理</a></li><li><a href="#">站点首页</a></li></ul></div></div>
</div>
</body>
</html>
3.index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>青城博雅教育首页</title>
</head><frameset cols="*" rows="136, *" id="frame_main" border="0"><frame th:src="@{/header}" noresize="noresize" name="header"><frameset cols="240, *"><frame th:src="@{/menu}" name="menu" /><frame th:src="@{/main}" name="main"></frameset>
</frameset><noframes><body>
</body>
</noframes></html>
4.login.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>用户登录</title>
<link href="css/login.css" rel="stylesheet" type="text/css" /><script th:src="@{/webjars/jquery/3.3.1/jquery.js}"></script><script>function login() {$("form").submit();}</script>
</head>
<body><div id="login"><div id="top"><div id="top_left"><img src="images/login_03.gif" /></div><div id="top_center"></div></div><form th:action="@{/toLogin}" method="post"><div id="center"><div id="center_left"></div><div id="center_middle"><div style="text-align: center; color: red" th:text="${tip}"></div><div id="user">用 户<input type="text" name="username" /></div><div id="password">密 码<input type="password" name="password" /></div><div id="btn"><a href="#" onclick="login()">登录</a><a href="#">清空</a></div></div><div id="center_right"></div></div></form><div id="down"><div id="down_left"><div id="inf"><span class="inf_text">版本信息</span><span class="copyright">v2.0</span></div></div><div id="down_center"></div></div></div>
</body>
</html>
5.main.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
body {font-family: Arial, Helvetica, sans-serif; font-size:12px; text-align:center;}
a { text-decoration: none;}
#all {widht: 100%; text-align:center; margin:auto;}
main {width: 96%; line-height: 1.8; margin:auto; border:1px #ccc dashed; text-align: left; text-indent: 2em;}
.mt{width: 1000px;border:1px solid #aca7a7 ;border-collapse: collapse;
}
.mt td{border: 1px solid #aca7a7;
}</style>
</head><body>
<div id="all"><div><a th:href="@{/add}">添加</a></div><table class="mt"><tr><td>用户名</td><td>姓名</td><td>地址</td><td>性别</td><td>生日</td><td>操作</td></tr><tr th:each="p:${list}"><td th:text="${p.username}"></td><td th:text="${p.pname}"></td><td th:text="${p.pAddr}"></td><td th:text="${p.gender==1}?'男':'女'"></td><td th:text="${#calendars.format(p.birth,'yyyy-MM-dd')}"></td><td><a th:href="@{/getPerson(pid=${p.pid})}">修改</a><a th:href="@{/delete(pid=${p.pid})}" >删除</a></td></tr></table></div>
</body>
</html>
6.menu.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title><link href="css/menu.css" rel="stylesheet" type="text/css" />
</head><body>
<div id="all"><div id="menu"><ul><li><img src="images/li.jpg" /> <a href="/main" target="main">员工管理</a></li><li><img src="images/li.jpg" /> <a href="" target="main">部门管理</a></li><li><img src="images/li.jpg" /> <a href="" target="main">绩效管理</a></li><li><img src="images/li.jpg" /> <a href="" target="main">财务管理</a></li></ul></div>
</div>
</body>
</html>
7.update.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
body {font-family: Arial, Helvetica, sans-serif; font-size:12px; text-align:center;}
a { text-decoration: none;}
#all {widht: 100%; text-align:center; margin:auto;}
main {width: 96%; line-height: 1.8; margin:auto; border:1px #ccc dashed; text-align: left; text-indent: 2em;}
.mt{width: 1000px;border:1px solid #aca7a7 ;border-collapse: collapse;
}
.mt td{border: 1px solid #aca7a7;
}</style>
</head><body>
<div id="all"><form th:action="@{/updatePerson}" method="post"><input type="hidden" name="pid" th:value="${p.pid}"/><table class="mt"><tr><td>用户名</td><td><input type="text" name="username" th:value="${p.username}"/></td><td>密码</td><td><input type="text" name="password" th:value="${p.password}"/></td><td>姓名</td><td><input type="text" name="pname" th:value="${p.pname}"/></td><td>地址</td><td><input type="text" name="pAddr" th:value="${p.pAddr}"/></td><td>性别</td><td><select name="gender"><option value="1" th:selected="${p.gender}==1">男</option><option value="2" th:selected="${p.gender}==2">女</option></select></td><td>生日</td><td><input type="text" name="birth" th:value="${#calendars.format(p.birth,'yyy-MM-dd')}"/></td><td><input type="submit" value="提交"/></td></tr></table></form>
</div>
</body>
</html>
css
1.header.css
body {background: #686868; font-family:Arial, Helvetica, sans-serif; font-size:12px; margin:0px; margin-bottom:2px;border-bottom: 1px #ccc solid;}
h1 {color: #FFF;}
a {color: #FFF; text-decoration: none;/*防止滤镜下链接失效*/position:relative;}
ul { list-style:none;}
#all {width: 100%;}
#banner {margin-top: 8px; margin-left: 32px;}
#main {width: 100%; margin-bottom: 2px; background:#eeeeee; margin-left: 0px; margin-right:0px; height: 30px; color: #000; line-height: 2.4;overflow: auto;}
#main a {color:#000;}
#welcome { float:left; width: 40%; font-weight: 800; padding-left: 8px; position:relative;}
#adminop { float:left; width: 59%; position:relative; text-align:right; line-height:1; *line-height:2.2;}
#adminop ul li {float: right; width: 80px;}
#nav {width: 100%; clear: both;}
#nav ul li {float: right; width:82px; height:25px; line-height: 2.1; text-align: center;}
.inactive { background-image/**/:url(../images/admin/nav_bg_inactive2.png) !important;background: none; margin-left: 2px; margin-right:2px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=images/admin/nav_bg_inactive2.png);}
.inactive a {color: #000;}
.active {background:url(../images/admin/nav_bg_active2.png) !important;background: none; margin-left: 2px; margin-right:2px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=images/admin/nav_bg_active2.png);}
.active a {color:#fff;}
.blankgray {background:#bbb; height:2px; width:100%; margin:0; padding:0; clear:both; font-size:2px;}
2.login.css
body{margin:0; padding:0; font-size:9pt;}
#login{margin:auto; width:975px; height:368px; margin-top:120px;}
#top_left{width:691px; height:89px; float:left;}
#top_left img {margin-left:33px;}
#top_center{width:248px; height:89px; background:url(../images/03.jpg); float:left;}#center_left{width:691px; height:190px; background:url(../images/04.jpg); float:left;}
#center_middle{width:248px; height:220px; float:left; background:url(../images/login_13.gif) repeat-y;}
#center_right{width:36px; height:190px; float:right; background:url(../images/login_11.gif);}#down_left{width:691px; height:89px; float:left; margin-top:15px;}
#down_center{width:248px; height:89px; background:url(../images/login_16.gif); float:left;}
#inf{width:691px; height:38px; background:url(../images/login_18.gif) no-repeat; }
.inf_text{display:block; width:100px; height:20px; font-size:16px; font-weight:bolder; color:#fff; margin-left:17px; margin-top:12px; float:left;}
.copyright{display:block; float:left; margin-left:17px; margin-top:15px;}#user{ margin-left:40px; margin-top:45px; height:25px;}
#password{margin-left:40px; margin-top:25px; height:25px;}
input{width:120px; height:18px; border:solid 1px #aca7a7; font-size:9pt;}
#btn{margin-left:30px; margin-top:40px;height:25px; margin-right:28px; text-align:center;}
#btn a{display:block; line-height:25px; background: url(../images/bt_bg.gif); border: solid 1px #b6b6b6; width:65px; float:left; margin-left:15px; text-decoration:none; color:#000;}
3.menu.css
html, body {height:100%;overflow:hidden;} /*为兼容ie7,ff*/
body {font-family:Arial, Helvetica, sans-serif; font-size:12px; margin:0px; text-align:center; border-right:1px #ccc solid;}
a {color: #000; text-decoration: none;}
#menu img {_margin-top: 12px;}/*没办法,ie6对list-style-image支持不好*/
#all {width: 100%;height:100%;}
#menu {width: 96%;}
#menu ul {padding:0; margin: 0; list-style: none;}
#menu ul li {background-image:url(../images/match/public/images/menu_bg.gif); background-repeat: repeat-x; background-position:center; height: 32px;;margin-top: 2px; margin-bottom: 2px; border:1px #ccc solid; line-height: 2.8;}
4.style.css
@CHARSET "UTF-8";
.pro{height: 8px;background-color: #4C4C4C;width: 500px;cursor: pointer;}.playball{height: 8px;width: 8px;background-color: orange;position: relative;}.time{width: 500px;height: 20px;border: 1px solid black;
}
controller代码
package cn.tx.springboot.controller;import cn.tx.springboot.model.TxPerson;
import cn.tx.springboot.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.Mapping;
import org.springframework.web.bind.annotation.RequestMapping;import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;@Controller
//@Repository
public class TxPersonController {@AutowiredPersonService personService;@RequestMapping("/main")public String main(Model model){List<TxPerson> list = personService.select();model.addAttribute("list",list);return "main";}@RequestMapping("/insert")public String insert(TxPerson person){personService.insert(person);return "redirect:main";}@RequestMapping("/getPerson")public String getPerson(int pid,Model model){TxPerson person = personService.getPersonById(pid);model.addAttribute("p",person);return "update";}@RequestMapping("/updatePerson")public String update(TxPerson person){personService.updatePerson(person);return "redirect:main";}@RequestMapping("/delete")public String delete(int pid){personService.delete(pid);return "redirect:main";}@RequestMapping("/toLogin")public String login(String username, String password, HttpSession session, Model model){Map<String, String> map = new HashMap<String, String>();map.put("username", username);map.put("password", password);TxPerson txPerson = personService.getPersonUsepass(map);model.addAttribute("p",txPerson);if (txPerson!=null){session.setAttribute("user",txPerson);return "index";}else {model.addAttribute("tip","用户名或密码错误!");return "login";}}
}
⑤编写拦截类
package cn.tx.springboot.interceptor;import cn.tx.springboot.model.TxPerson;
import org.springframework.web.context.request.WebRequestInterceptor;
import org.springframework.web.servlet.HandlerInterceptor;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;public class LoginInterceptor implements HandlerInterceptor {@Overridepublic boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {TxPerson user = (TxPerson) request.getSession().getAttribute("user");if(user!=null){return true;}response.sendRedirect(request.getContextPath()+"/login");return false;}
}
三、测试
实现上面的过程后就可以访问页面了(随便访问一个controller中对应的路径即可,因为在配置中配置了跳转路径,所以不登录直接访问,访问任何页面都会被跳转到login.html页面)

注意: 我没有提供项目中的图片信息,所以打开可能并不是这个页面(图片自行下载微调前端即可)
相关文章:
SpringBoot项目实战(初级)
目录 一、数据库搭建 二、代码开发 1.pom.xml 2.thymeleaf模块处理的配置类 3.application配置文件 4.配置(在启动类中) 5.编写数据层 ②编写dao层 ③编写service层 接口 实现类 注意 补充(注入的3个注解) 1.AutoWir…...
合成层优化
以下是关于 合成层(Composite Layer)优化 的系统梳理,涵盖基础原理、触发条件、优化策略及进阶实践,帮助深入理解如何通过分层渲染提升页面性能: 一、合成层基础概念 1. 什么是合成层? 定义:浏览器将页面元素提升为独立的图形层(Graphics Layer),由 GPU 单独处理,避…...
什么是MCP|工作原理是什么|怎么使用MCP|图解MCP
写在前面 Manus的爆火似乎推动了MCP的出圈,虽然Manus没有用MCP。这篇文章我们就讲讲MCP,当然我也是最近才学习到MCP的,如果理解有误的地方,欢迎评论区指出! 1. 为什么需要MCP? 1.1 LLM 现状 我们都知道…...
《Partial-label learning with a guided Prototypical classifier》23年CVPR 文献速读
论文地址 1. 引言 本文介绍了一种用于部分标签学习(Partial-Label Learning, PLL)的新框架 PaPi(Partial-label learning with a guided Prototypical classifier),旨在提高在视觉任务中处理部分标签数据时的性能。部…...
GitLens with `Commit Graph`
文章目录 GitLens with Commit Graph GitLens with Commit Graph 自己打包的 GitLens,能够查看 commit graph。 GitLens 持续更新中 下载之后,通过 VSCode 插件直接安装即可使用。...
python每日十题(6)
】函数定义:函数是指一组语句的集合通过一个名字(函数名)封装起来,要想执行这个函数,只需要调用其函数名即可。函数能提高应用的模块性和代码的重复利用率 在Python语言中,用关键字class来定义类 在Python语…...
UniRel论文复现过程中的问题解决办法(全)
注解写在前面:本文仅为解决各位同学在复现时面对的问题,有问题可以评论,看见会回复!!! [顶刊论文]UniRel:Unified Representation and Interaction for Joint Relational Triple Extraction2022.11.16&…...
js逆向之断点调试
1.XHR/提取断点用法 当刷新页面时候,有大量请求,并且你无法定位参数信息的时候,或者参数被混淆无法搜到,可以用该方法,该方法是会捕获所有请求连接,然后我们通过连接过滤出自己想要的请求,然后…...
Unity Shader编程】之渲染流程之深度及pass详解
关于透明物体的渲染,首先需要了解以下部分 深度缓冲区深度写入深度测试pass渲染和深度测试的过程深度测试和颜色混合过程 ** 一,深度缓冲区 ** 深度即物体距离相机的距离,深度写入即是把物体的距离相机信息记录下来,写入一个名…...
【算法笔记】图论基础(一):建图、存图、树和图的遍历、拓扑排序、最小生成树
目录 何为图论图的概念 图的一些基本概念有向图和无向图带权图连通图和非连通图对于无向图对于有向图 度对于无向图对于有向图一些结论 环自环、重边、简单图、完全图自环重边简单图 稀疏图和稠密图子图、生成子图同构 图的存储直接存边邻接矩阵存边邻接表存边链式前向星存边 图…...
Compose 原理解析
Compose 的组件都是放在 setContent() 之后才能显示的,那需要先看看这个函数的作用。 先看 ComponentActivity 的扩展函数 setContent(): /*** 将给定的可组合项合成到给定的 Activity 中。[content] 将成为给定 Activity 的根视图。* 这大致相当于使用…...
pyspark学习rdd处理数据方法——学习记录
python黑马程序员 """ 文件,按JSON字符串存储 1. 城市按销售额排名 2. 全部城市有哪些商品类别在售卖 3. 上海市有哪些商品类别在售卖 """ from pyspark import SparkConf, SparkContext import os import jsonos.environ[PYSPARK_P…...
个人学习编程(3-22) leetcode刷题
连续子数组:(难) 示例 1: 输入: nums [0,1] 输出: 2 说明: [0, 1] 是具有相同数量 0 和 1 的最长连续子数组。 示例 2: 输入: nums [0,1,0] 输出: 2 说明: [0, 1] (或 [1, 0]) 是具有相同数量0和1的最长连续子数组。 需要理解的知识&a…...
RabbitMQ八股文
RabbitMQ 核心概念与组件 1. RabbitMQ 核心组件及其作用 1.1 生产者(Producer) 作用:创建并发送消息到交换机。特点:不直接将消息发送到队列,而是通过交换机路由。 1.2 交换机(Exchange) 作…...
运维面试题(七)
1.statefulset用来管理有状态的应用程序,有状态是什么意思? 每一个pod都有一个固定的网络标识符,在整个生命周期中不会改变。每个实例都可以拥有自己的持久化存储卷,即使容器被删除并重新创建,存储卷仍然存在。Statef…...
【项目设计】网页版五子棋
文章目录 一、项目介绍1.项目简介2.开发环境3.核心技术4.开发阶段 二、Centos-7.6环境搭建1.安装wget工具2.更换软件源(yum源)3.安装scl工具4.安装epel软件源5.安装lrzsz传输工具6.安装高版本gcc/g编译器7.安装gdb调试器8.安装git9.安装cmake10.安装boost库11.安装Jsoncpp库12.…...
Netty——BIO、NIO 与 Netty
文章目录 1. 介绍1.1 BIO1.1.1 概念1.1.2 工作原理1.1.3 优缺点 1.2 NIO1.2.1 概念1.2.2 工作原理1.2.3 优缺点 1.3 Netty1.3.1 概念1.3.2 工作原理1.3.3 优点 2. Netty 与 Java NIO 的区别2.1 抽象层次2.2 API 易用性2.3 性能优化2.4 功能扩展性2.5 线程模型2.6 适用场景 3. 总…...
Docker 安装 Mysql
以下是安装Docker版MySQL 8.0.25并实现目录挂载的步骤: docker仓库:https://hub.docker.com/_/mysql 1. 拉取Mysql镜像文件 docker pull mysql:8.0.252. 创建mysql临时容器服务 docker run -d \--name mysql \-p 3306:3306 \-e MYSQL_ROOT_PASSWORD123…...
Electron打包文件生成.exe文件打开即可使用
1 、Electron 打包,包括需要下载的内容和环境配置步骤 注意:Electron 是一个使用 JavaScript、HTML 和 CSS 构建跨平台桌面应用程序的框架 首先需要电脑环境有Node.js 和 npm我之前的文章有关nvm下载node的说明也可以去官网下载 检查是否有node和npm环…...
线程和协程的区别了解
1.资源消耗 调度方式:线程由操作系统内核调度(抢占式),协程由程序自己控制调度(协作式)。切换开销:线程切换涉及内核态与用户态的转换,开销大;协程只在用户态切换上下文…...
楼宇自控系统的结构密码:总线与分布式结构方式的差异与应用
在现代建筑中,为了实现高效、智能的管理,楼宇自控系统变得越来越重要。它就像建筑的 智能管家,可自动控制照明、空调、通风等各种机电设备,让建筑运行更顺畅,还能节省能源成本。而在楼宇自控系统里,有两种关…...
算法及数据结构系列 - 滑动窗口
系列文章目录 算法及数据结构系列 - 二分查找 算法及数据结构系列 - BFS算法 算法及数据结构系列 - 动态规划 算法及数据结构系列 - 双指针 算法及数据结构系列 - 回溯算法 算法及数据结构系列 - 树 文章目录 滑动窗口框架思路经典题型76. 最小覆盖子串567. 字符串的排列438. …...
【江协科技STM32】软件SPI读写W25Q64芯片(学习笔记)
SPI通信协议及S为5Q64简介:【STM32】SPI通信协议&W25Q64Flash存储器芯片(学习笔记)-CSDN博客 STM32与W25Q64模块接线: SPI初始化: 片选SS、始终SCK、MOSI都是主机输出引脚,输出引脚配置为推挽输出&…...
2025.3.23机器学习笔记:文献阅读
2025.3.23周报 题目信息摘要Abstract创新点网络架构实验不足以及展望 题目信息 题目: Enhancement of Hydrological Time Series Prediction with Real-World Time Series Generative Adversarial Network-Based Synthetic Data and Deep Learning Models期刊&…...
Day20-前端Web案例——部门管理
目录 部门管理1. 前后端分离开发2. 准备工作2.1 创建Vue项目2.2 安装依赖2.3 精简项目 3. 页面布局3.1 介绍3.2 整体布局3.3 左侧菜单 4. Vue Router4.1 介绍4.2 入门4.3 案例4.4 首页制作 5. 部门管理5.1部门列表5.1.1. 基本布局5.1.2 加载数据5.1.3 程序优化 5.2 新增部门5.3…...
实验3 以太坊交易周期的需求分析
区块链技术 实验报告 实验名称 实验3 以太坊交易周期的需求分析 一、实验目的 1、学习并掌握以太坊交易的内容; 2、学习并掌握以太坊交易周期的四个阶段; 3、学习并掌握结构化需求分析方法; 4、学习并掌握面向对象的需求分析方法&…...
Linux 通过压缩包安装 MySQL 并设置远程连接教程
一、引言 在 Linux 系统中,有时候我们需要通过压缩包的方式手动安装 MySQL 数据库,并且为了方便在其他设备上对数据库进行管理和操作,还需要设置允许远程连接。本文将详细介绍在 Linux(以 CentOS 为例)系统中通过压缩包安装 MySQL 8 并设置远程连接的步骤。 二、安装前准…...
【商城实战(56)】商城数据生命线:恢复流程与演练全解析
【商城实战】专栏重磅来袭!这是一份专为开发者与电商从业者打造的超详细指南。从项目基础搭建,运用 uniapp、Element Plus、SpringBoot 搭建商城框架,到用户、商品、订单等核心模块开发,再到性能优化、安全加固、多端适配…...
Java学习笔记-XXH3哈希算法
XXH3是由Yann Collet设计的非加密哈希算法,属于XXHash系列的最新变种,专注于极速性能与低碰撞率,适用于对计算效率要求极高的场景。 极速性能 在RAM速度限制下运行,小数据(如 1-128 字节)处理可达纳秒级&…...
同旺科技USB to SPI 适配器 ---- 指令循环发送功能
所需设备: 内附链接 1、同旺科技USB to SPI 适配器 1、周期性的指令一次输入,即可以使用 “单次发送” 功能,也可以使用 “循环发送” 功能,大大减轻发送指令的编辑效率; 2、 “单次发送” 功能,“发送数据…...
在Mac M1/M2芯片上完美安装DeepCTR库:避坑指南与实战验证
让推荐算法在Apple Silicon上全速运行 概述 作为推荐系统领域的最经常用的明星库,DeepCTR集成了CTR预估、多任务学习等前沿模型实现。但在Apple Silicon架构的Mac设备上,安装过程常因ARM架构适配、依赖库版本冲突等问题受阻。本文通过20次环境搭建实测…...
【CXX-Qt】2.5 继承
某些 Qt API 要求你从抽象基类中重写某些方法,例如 QAbstractItemModel。 为了支持直接从 Rust 中创建这样的子类,CXX-Qt 提供了多种辅助工具。 某些基类可能需要特殊的构造参数。这可以通过使用自定义构造函数来实现。 访问基类方法 要在 Rust 中访…...
Linux系统之美:环境变量的概念以及基本操作
本节重点 理解环境变量的基本概念学会在指令和代码操作上查询更改环境变量环境变量表的基本概念父子进程间环境变量的继承与隔离 一、引入 1.1 自定义命令(我们的exe) 我们以往的Linux编程经验告诉我们,我们在对一段代码编译形成可执行文件后…...
【nnUnetv2】推理+评估+测试
在 Windows 系统下设置环境变量 之前训练和推理的时候开着AutoDL的服务器,是在 Linux 系统下设置的环境变量。 但是现在开始研究具体代码了,就在本地跑(一直开着服务器有点费钱),所以就在Windows 系统下设置环境变量。 ①右键点击 “此电脑”,选择 “属性”。 ②在左侧…...
损失函数理解(一)——极大似然估计
本博客内容来自B站up主【王木头学科学】的视频内容 习惯看视频的小伙伴可移至视频链接[待补充]:~~~ 首先通俗地解释一下极大似然估计(Maximum Likelihood Estimation,MLE)的思想:通过结果寻找使该结果发生的最可能的原…...
ios端使用TCplayer直播播放三秒直接卡顿bug
1. 查看配置项没问题 setTcPlayer() {let that this;player new TcPlayer("videoPlayer", {live: this.activatPlayType "livePlay" ? true : false,x5_type: "h5",x5_fullscreen: true,systemFullscreen: true,x5_orientation: 1,x5_player…...
大模型-提示词工程与架构
什么是提示工程 提示工程(Prompt Engineering)是一门新兴的技术领域,专注于研究如何设计、构建和优化提示词,以充分发挥大模型的潜力 。它涉及到对语言结构、任务需求、模型特性等多方面因素的综合考量。提示工程的目标是通过精心…...
高斯数据库-WDR Snapshot生成性能报告
docker 安装高斯数据库: docker pull opengauss/opengauss:latestdocker run --name opengauss --privilegedtrue -d -e GS_PASSWORDopenGauss123 -p 8090:5432 -v /opengauss:/var/lib/opengauss/data opengauss/opengauss:latest 进入容器设置用户权限ÿ…...
损失函数理解(二)——交叉熵损失
损失函数的目的是为了定量描述不同模型(例如神经网络模型和人脑模型)的差异。 交叉熵,顾名思义,与熵有关,先把模型换成熵这么一个数值,然后用这个数值比较不同模型之间的差异。 为什么要做这一步转换&…...
CSS学习笔记
【1】CSS样式规则 【2】CSS样式表引入方式 1、行内式 <!DOCTYPE html> <html lang"zh-CN"> <head><meta charset"UTF-8"><meta http-equiv"X-UA-Compatible" content"IEedge"/><meta name"vi…...
AI比人脑更强,因为被植入思维模型【15】马斯洛需求层次理论
马斯洛需求层次模型思维模型 定义 马斯洛需求层次模型是由美国心理学家亚伯拉罕马斯洛(Abraham Maslow)于1943年提出的一种心理学理论,用于描述人类动机的层次结构。该模型将人类的需求从低到高分为五个层次,分别是生理需求、安…...
cartographer中地图转换
文章目录 地图种类栅格地图 坐标系种类ros坐标系像素坐标系物理坐标系(世界坐标系) 地图种类 栅格地图 地图的初始化 在Cartographer中,栅格地图通过概率值来表示每个栅格的状态。每个栅格的初始概率值通常设置为0.5,表示未知状态。这种初始化方式允许…...
关于MTU的使用(TCP/IP网络下载慢可能与此有关)
参考链接:告诉你mtu值怎么设置才能网速最好! -Win7系统之家 出现网络速度被限制,可能与MTU值相关,先查看下本机的MTU winR,然后输入:netsh interface ipv4 show subinterfaces ,查看自己网络中的MTU&…...
【AI解题】Cache直接映射地址划分解析
一、问题背景 某32位总线处理器的Cache采用直接映射方式,已知 Cache总容量为16KB,每个Cache块大小为16字节。需要确定内存地址中 Offset(块内偏移)、Index(块索引)、Tag(标签) 三部…...
android音频概念解析
音频硬件接口(我们可以理解为ASOC的声卡) 官方代码里叫audio hardware interface 也称为module,定义在services/audiopolicy/config/audio_policy_configuration.xml: 分别有primary,a2dp,usb࿰…...
项目生命周期 和 项目管理生命周期的差异
在项目管理中,明确区分 项目生命周期 和 项目管理生命周期 是理解项目运作的关键。以下从定义、阶段划分到实际应用进行系统性分析: 一、项目生命周期(Project Life Cycle) 定义 项目生命周期是项目从 启动到结束 的自然演进过程,描述项目交付成果的 技术性阶段,通常与…...
UDP 协议
文章目录 UDP 协议简介数据包格式UDP 通信流程抓包分析参考 本文为笔者学习以太网对网上资料归纳整理所做的笔记,文末均附有参考链接,如侵权,请联系删除。 UDP 协议 UDP 是一种面向无连接的传输层协议,属于 TCP/IP 协议簇的一种。…...
[已解决]jupyter notebook报错 500 : Internal Server Error及notebook闪退
jupyter notebook出现如上图的报错,可以在黑色窗口中检查是为什么报错。 我检查发现是nbconvert导致的问题,卸载重装nbconvert。 但是这时候出现,jupyter notebook闪退问题。jupyter的黑色窗口出现一秒钟就没了。 在Anaconda Prompt中检查ju…...
APM 仿真遥控指南
地面站开发了一段时间了,由于没有硬件,所以一直在 APM 模拟器中验证。我们已经实现了 MAVLink 消息接收和解析,显示无人机状态,给无人机发送消息,实现一键起飞,飞往指定地点,降落,返…...
使用 ncurses 库创建文本用户界面:基础函数详解
简介 ncurses 是一个功能强大的库,用于在 Unix-like 系统中创建文本用户界面。它提供了丰富的函数来控制屏幕上的文本显示、处理键盘输入、绘制图形元素等。本文将详细介绍 ncurses 库中的一些基础函数,包括 printw、wrefresh、获取用户信息、键盘输入、…...