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

门户网站开发架构/购买友情链接网站

门户网站开发架构,购买友情链接网站,哪里有建网站的,网站竞价托管转载自&#xff1a; www.javaman.cn 博客系统访问&#xff1a; http://175.24.198.63:9090/front/index 登录功能 1、前端页面 采用的是layui-admin框架&#xff0c;文中的验证码内容&#xff0c;请参考作者之前的验证码功能 <!DOCTYPE html> <html lang"zh…

转载自: www.javaman.cn
博客系统访问: http://175.24.198.63:9090/front/index
在这里插入图片描述

登录功能

1、前端页面

采用的是layui-admin框架,文中的验证码内容,请参考作者之前的验证码功能

<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head><title>ds博客</title><div th:replace="common/link::header"></div><link rel="stylesheet" th:href="@{/static/layuiadmin/style/login.css}" media="all">
</head>
<body>
<div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;"><div class="layadmin-user-login-main"><div class="layadmin-user-login-box layadmin-user-login-header"><h2>ds博客</h2><p>后台登录</p></div><div class="layadmin-user-login-box layadmin-user-login-body layui-form"><div class="layui-form-item"><label class="layadmin-user-login-icon layui-icon layui-icon-username" for="LAY-user-login-username"></label><input type="text" name="userName" value="test" id="LAY-user-login-username" lay-verify="required" placeholder="用户名" class="layui-input"></div><div class="layui-form-item"><label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password"></label><input type="password" name="passWord" value="test" id="LAY-user-login-password" lay-verify="required" placeholder="密码" class="layui-input"></div><div class="layui-form-item"><div class="layui-row"><div class="layui-col-xs7"><label class="layadmin-user-login-icon layui-icon layui-icon-vercode"></label><input type="text" name="code"  lay-verify="required" placeholder="图形验证码" class="layui-input"></div><div class="layui-col-xs5"><div style="margin-left: 10px;"><img id="codeImg" class="layadmin-user-login-codeimg"></div></div></div></div><div class="layui-form-item" style="margin-bottom: 20px;"><input type="checkbox" name="remember-me" lay-skin="primary" title="记住密码"></div><div class="layui-form-item"><button class="layui-btn layui-btn-fluid layui-bg-blue"  lay-submit lay-filter="login">登 录</button></div></div></div><!--    <div class="layui-trans layadmin-user-login-footer">-->
<!--        <p>版权所有 © 2022 <a href="#" target="_blank">济南高新开发区微本地软件开发工作室</a> 鲁ICP备20002306号-1</p>-->
<!--    </div>-->
</div>
<div th:replace="common/script::footer"></div>
<script th:inline="javascript">layui.config({base: '/static/layuiadmin/' //静态资源所在路径}).extend({index: 'lib/index' //主入口模块}).use(['index', 'user'], function(){let $ = layui.$,form = layui.form;// 初始化getImgCode();form.render();//提交form.on('submit(login)', function(obj) {// 打开loadinglet loading = layer.load(0, {shade: false,time: 2 * 1000});// 禁止重复点击按钮$('.layui-btn').attr("disabled",true);//请求登入接口$.ajax({type: 'POST',url:  ctx + '/login',data: obj.field,dataType: 'json',success: function(result) {if (result.code === 200) {layer.msg('登入成功', {icon: 1,time: 1000}, function(){window.location.href = '/';});} else {layer.msg(result.message);// 刷新验证码getImgCode();// 关闭loadinglayer.close(loading);// 开启点击事件$('.layui-btn').attr("disabled", false);}}});});$("#codeImg").on('click', function() {// 添加验证码getImgCode();});$(document).keydown(function (e) {if (e.keyCode === 13) {$('.layui-btn').click();}});// 解决session过期跳转到登录页并跳出iframe框架$(document).ready(function () {if (window != top) {top.location.href = location.href;}});});/*** 获取验证码*/function getImgCode() {let url = ctx + '/getImgCode';let xhr = new XMLHttpRequest();xhr.open('GET', url, true);xhr.responseType = "blob";xhr.onload = function() {if (this.status === 200) {let blob = this.response;document.getElementById("codeImg").src = window.URL.createObjectURL(blob);}}xhr.send();}
</script>
</body>
</html>
2、后端处理/login请求

在这里插入图片描述

通过springsecurity的.loginProcessingUrl(“/login”)处理,处理逻辑如下:

.loginProcessingUrl("/login") 用于指定处理登录操作的URL地址,而具体的验证逻辑是由 Spring Security 提供的认证过滤器链负责的。在Spring Security中,主要的认证过程是由UsernamePasswordAuthenticationFilter来完成的。

当用户提交登录表单,请求到达.loginProcessingUrl("/login")配置的URL时,UsernamePasswordAuthenticationFilter会拦截这个请求,然后进行以下主要步骤:

  1. 获取用户名和密码:从请求中获取用户输入的用户名和密码。

  2. 创建认证令牌:使用获取到的用户名和密码创建一个认证令牌(UsernamePasswordAuthenticationToken)。

  3. 将认证令牌传递给认证管理器:将认证令牌传递给配置的认证管理器(AuthenticationManager)进行认证。

  4. 执行认证逻辑:认证管理器会调用已配置的身份验证提供者(AuthenticationProvider)来执行实际的身份验证逻辑。通常,会使用用户提供的用户名和密码与系统中存储的用户信息进行比对。

  5. 处理认证结果:认证提供者返回认证结果,如果认证成功,则将认证令牌标记为已认证,并设置用户权限等信息。如果认证失败,会抛出相应的异常。

  6. 处理认证成功或失败:根据认证的结果,UsernamePasswordAuthenticationFilter将请求重定向到成功或失败的处理器,执行相应的操作,比如跳转页面或返回错误信息。

这个整个过程是由 Spring Security 提供的默认配置完成的,通常情况下,开发者只需要配置好认证管理器、用户信息服务(UserDetailsService),以及成功和失败的处理器,Spring Security 就会负责处理登录验证的整个流程。

package com.ds.core.config;import com.ds.blog.system.service.SysUserService;
import com.ds.core.security.CustomAccessDeniedHandler;
import com.ds.core.security.DefaultAuthenticationFailureHandler;
import com.ds.core.security.DefaultAuthenticationSuccessHandler;
import com.ds.core.security.filter.ValidateCodeFilter;
import net.bytebuddy.asm.Advice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class MySecurityConfig extends WebSecurityConfigurerAdapter {@Overrideprotected void configure(HttpSecurity http) throws Exception {http.authorizeRequests()// 放过.antMatchers("/loginPage", "/getImgCode").permitAll().antMatchers("/**/*.jpg", "/**/*.png", "/**/*.gif", "/**/*.jpeg").permitAll()// 剩下的所有的地址都是需要在认证状态下才可以访问.anyRequest().authenticated().and()// 过滤登录验证码.addFilterBefore(validateCodeFilter, UsernamePasswordAuthenticationFilter.class)// 配置登录功能.formLogin().usernameParameter("userName").passwordParameter("passWord")// 指定指定要的登录页面.loginPage("/loginPage")// 处理认证路径的请求.loginProcessingUrl("/login").successHandler(defaultAuthenticationSuccessHandler).failureHandler(defaultAuthenticationFailureHandler).and().exceptionHandling().accessDeniedHandler(accessDeniedHandler).and()// 登出.logout().invalidateHttpSession(true).deleteCookies("remember-me").logoutUrl("/logout").logoutSuccessUrl("/loginPage").and().rememberMe()// 有效期7天.tokenValiditySeconds(3600 * 24 * 7)// 开启记住我功能.rememberMeParameter("remember-me").and()//禁用csrf.csrf().disable()// header response的X-Frame-Options属性设置为SAMEORIGIN.headers().frameOptions().sameOrigin().and()// 配置session管理.sessionManagement()//session失效默认的跳转地址.invalidSessionUrl("/loginPage");}
}
3、登录成功监听器(记录登录日志)

创建监听器,在登录成功的时候记录登录日志。

  1. @Slf4j

    • @Slf4j 是 Lombok 提供的注解,用于自动生成日志对象,这里是为了方便使用日志。
  2. @Component

    • @Component 注解将类标识为一个 Spring 组件,使得 Spring 能够自动扫描并将其纳入容器管理。
  3. AuthenticationSuccessListener 实现 ApplicationListener 接口

    • AuthenticationSuccessListener 类实现了 ApplicationListener<AuthenticationSuccessEvent> 接口,表明它是一个事件监听器,监听的是用户认证成功的事件。
  4. SysLoginLogService 注入

    • SysLoginLogService 是一个服务类,通过 @Autowired 注解注入到当前类中。该服务类用于对登录日志的持久化操作。
  5. onApplicationEvent 方法

    • onApplicationEvent 方法是实现 ApplicationListener 接口的回调方法,在用户认证成功的时候会被触发。
    • 通过 authenticationSuccessEvent.getAuthentication().getPrincipal() 获取登录的用户信息,这里假设用户信息是 User 类型。
    • 通过 ServletUtil.getClientIP 获取客户端的IP地址,这里使用了 ServletUtil 工具类,可以通过请求上下文获取IP地址。
    • 创建一个 SysLoginLog 对象,将登录成功的相关信息设置进去,包括账号、登录IP、备注等。
    • 调用 sysLoginLogService.save(sysLoginLog) 将登录日志持久化存储。

总的来说,这段代码的作用是在用户成功登录后,通过监听 Spring Security 的认证成功事件,记录用户的登录日志信息,包括登录账号、登录IP和登录成功的备注。这样可以实现登录成功后的自定义操作,例如记录登录日志等。

@Slf4j
@Component
public class AuthenticationSuccessListener implements ApplicationListener<AuthenticationSuccessEvent> {@Autowiredprivate SysLoginLogService sysLoginLogService;@Overridepublic void onApplicationEvent(AuthenticationSuccessEvent authenticationSuccessEvent) {// 登录账号User user = (User) authenticationSuccessEvent.getAuthentication().getPrincipal();// 请求IPString ip = ServletUtil.getClientIP(((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(), "");SysLoginLog sysLoginLog = new SysLoginLog();sysLoginLog.setAccount(user.getUsername());sysLoginLog.setLoginIp(ip);sysLoginLog.setRemark("登录成功");sysLoginLogService.save(sysLoginLog);}
}
4、登录失败监听器(记录登录日志)

创建监听器,在登录失败的时候记录异常登录日志。

@Slf4j
@Component
public class AuthenticationFailureListener implements ApplicationListener<AbstractAuthenticationFailureEvent>  {@Autowiredprivate SysLoginLogService sysLoginLogService;@Overridepublic void onApplicationEvent(AbstractAuthenticationFailureEvent abstractAuthenticationFailureEvent) {// 登录账号String username = abstractAuthenticationFailureEvent.getAuthentication().getPrincipal().toString();// 登录失败原因String message ;if (abstractAuthenticationFailureEvent instanceof AuthenticationFailureBadCredentialsEvent) {//提供的凭据是错误的,用户名或者密码错误message = "提供的凭据是错误的,用户名或者密码错误";} else if (abstractAuthenticationFailureEvent instanceof AuthenticationFailureCredentialsExpiredEvent) {//验证通过,但是密码过期message = "验证通过,但是密码过期";} else if (abstractAuthenticationFailureEvent instanceof AuthenticationFailureDisabledEvent) {//验证过了但是账户被禁用message = "验证过了但是账户被禁用";} else if (abstractAuthenticationFailureEvent instanceof AuthenticationFailureExpiredEvent) {//验证通过了,但是账号已经过期message = "验证通过了,但是账号已经过期";} else if (abstractAuthenticationFailureEvent instanceof AuthenticationFailureLockedEvent) {//账户被锁定message = "账户被锁定";} else if (abstractAuthenticationFailureEvent instanceof AuthenticationFailureProviderNotFoundEvent) {//配置错误,没有合适的AuthenticationProvider来处理登录验证message = "配置错误";} else if (abstractAuthenticationFailureEvent instanceof AuthenticationFailureProxyUntrustedEvent) {// 代理不受信任,用于Oauth、CAS这类三方验证的情形,多属于配置错误message = "代理不受信任";} else if (abstractAuthenticationFailureEvent instanceof AuthenticationFailureServiceExceptionEvent) {// 其他任何在AuthenticationManager中内部发生的异常都会被封装成此类message = "内部发生的异常";} else {message = "其他未知错误";}// 请求IPString ip = ServletUtil.getClientIP(((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(), "");SysLoginLog sysLoginLog = new SysLoginLog();sysLoginLog.setAccount(username);sysLoginLog.setLoginIp(ip);sysLoginLog.setRemark(message);sysLoginLogService.save(sysLoginLog);}
}
5、认证成功处理器

下面是一个认证成功处理器,登录成功后,会返回响应的信息给前端

@Component
@Slf4j
public class DefaultAuthenticationSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler {@Overridepublic void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws ServletException, IOException {log.info("-----login in success----");response.setCharacterEncoding("utf-8");response.setContentType("application/json;charset=utf-8");PrintWriter writer = response.getWriter();writer.write(JSON.toJSONString(Result.success()));writer.flush();}
}
.successHandler(defaultAuthenticationSuccessHandler)
.failureHandler(defaultAuthenticationFailureHandler)
6、认证失败处理器

下面是一个认证成功处理器,登录成功后,会返回响应的信息给前端

@Component
@Slf4j
public class DefaultAuthenticationFailureHandler extends SimpleUrlAuthenticationFailureHandler {@Overridepublic void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException {log.info("login in failure : " +  exception.getMessage());response.setContentType("application/json;charset=utf-8");response.setCharacterEncoding("utf-8");PrintWriter writer = response.getWriter();String message;if (exception instanceof BadCredentialsException) {message =  "用户名或密码错误,请重试。";writer.write(JSON.toJSONString(Result.failure(message)));}else{writer.write(JSON.toJSONString(Result.failure(exception.getMessage())));}writer.flush();}
.successHandler(defaultAuthenticationSuccessHandler)
.failureHandler(defaultAuthenticationFailureHandler)
7、前端页面

返回200,就代表成功,跳转到/请求,进去index或者main页面

if (result.code === 200) {layer.msg('登入成功', {icon: 1,time: 1000}, function(){window.location.href = '/';});
} else {

在这里插入图片描述

总结

AuthenticationSuccessEvent 是 Spring Security 中用于表示用户认证成功的事件。判断登录成功的主要依据是在认证过程中,用户提供的凭据(通常是用户名和密码)与系统中存储的凭据匹配。以下是判断登录成功的基本流程:

  1. 用户提交登录表单
    • 用户在浏览器中输入用户名和密码,然后点击登录按钮,提交登录表单。
  2. Spring Security 拦截登录请求
    • 配置的 .loginProcessingUrl("/login") 指定了登录请求的URL,Spring Security会拦截这个URL的请求。
  3. UsernamePasswordAuthenticationFilter处理登录请求
    • UsernamePasswordAuthenticationFilter 是 Spring Security 内置的过滤器之一,用于处理用户名密码登录认证。
    • 当用户提交登录表单时,UsernamePasswordAuthenticationFilter会拦截该请求,尝试进行身份验证。
  4. AuthenticationManager执行身份验证
    • UsernamePasswordAuthenticationFilter将用户名密码等信息封装成一个 UsernamePasswordAuthenticationToken
    • 通过 AuthenticationManager 进行身份验证,AuthenticationManager 是一个接口,实际的实现为 ProviderManager
    • ProviderManager通过配置的 AuthenticationProvider 来执行实际的身份验证逻辑。
  5. AuthenticationProvider处理身份验证
    • DaoAuthenticationProviderAuthenticationProvider 的默认实现之一,用于处理基于数据库的身份验证。
    • DaoAuthenticationProvider会从配置的 UserDetailsService 中获取用户信息,然后与用户提交的信息进行比对。
  6. 认证成功
    • 如果认证成功,AuthenticationProvider 会返回一个已认证的 Authentication 对象。
    • 这个已认证的 Authentication 对象包含了用户的信息,通常是 UserDetails 的实现。
  7. AuthenticationSuccessHandler处理认证成功
    • 在配置中,通过 .successHandler() 方法指定了处理认证成功的 AuthenticationSuccessHandler
    • 在这个处理器中,可以执行一些额外的逻辑,例如记录登录日志等。
  8. AuthenticationSuccessEvent被发布
    • 在处理成功的阶段,Spring Security 发布了 AuthenticationSuccessEvent 事件,表示认证成功。

在上述流程中,认证成功的判断主要是在 AuthenticationProvider 中完成的。DaoAuthenticationProvider 会检查用户提供的密码与数据库中存储的密码是否匹配。如果匹配,就认为认证成功。当认证成功后,后续的处理流程包括 AuthenticationSuccessHandler 的执行和 AuthenticationSuccessEvent 的发布。你可以通过监听 AuthenticationSuccessEvent 事件来执行一些额外的自定义逻辑,例如记录登录日志。

在这里插入图片描述

相关文章:

springboot listener、filter登录实战

转载自&#xff1a; www.javaman.cn 博客系统访问&#xff1a; http://175.24.198.63:9090/front/index 登录功能 1、前端页面 采用的是layui-admin框架&#xff0c;文中的验证码内容&#xff0c;请参考作者之前的验证码功能 <!DOCTYPE html> <html lang"zh…...

【数据结构—栈的实现(数组栈)】

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录 前言 一、栈 1.1栈的概念及结构 二、栈的实现 2.1头文件的实现—Stack.h 2.2源文件的实现—Stack.c 2.3源文件的测试—test.c 三、栈的实际测试数据展示 3.1正常的出…...

Linux安装Halo(个人网站)

项目简介 1.代码开源:Halo 的项目代码开源在 GitHub 上且处于积极维护状态&#xff0c;截止目前已经发布了 109 个版本。你也可以在上面提交你的问题或者参与代码贡献。2.易于部署:推荐使用 Docker 的方式部署 Halo&#xff0c;便于升级&#xff0c;同时避免了各种环境依赖的问…...

Java - Spring中Bean的循环依赖问题

什么是Bean的循环依赖 A对象中有B属性。B对象中有A属性。这就是循环依赖。我依赖你&#xff0c;你也依赖我。 比如&#xff1a;丈夫类Husband&#xff0c;妻子类Wife。Husband中有Wife的引用。Wife中有Husband的引用。 Spring解决循环依赖的机理 Spring为什么可以解决set s…...

使用 Python 实现简单的爬虫框架

爬虫是一种自动获取网页内容的程序&#xff0c;它可以帮助我们从网络上快速收集大量信息。在本文中&#xff0c;我们将学习如何使用 Python 编写一个简单的爬虫框架。 一、请求网页 首先&#xff0c;我们需要请求网页内容。我们可以使用 Python 的 requests 库来发送 HTTP 请…...

Activiti七大接口,28张表详解

Activiti七大接口&#xff0c;28张表详解 7大接口 RepositoryService&#xff1a;提供管理流程部署和流程定义API。 RuntimeService&#xff1a;提供运行时流程实例进行管理与控制API。 TaskService&#xff1a;提供流程任务管理API。 IdentityService&#xff1a;提供对流程…...

解决msvcr120.dll文件丢失问题

项目场景&#xff1a; 在VMware虚拟机中安装win7家庭版系统&#xff0c;安装MySQL数据库&#xff0c;部署项目文件。 问题描述 安装MySQL数据库过程中提示“msvcr120.dll文件丢失”。 原因分析&#xff1a; 提示丢失msvcr120.dll文件&#xff0c;我们首先要到C:\Windows\Sys…...

AI日报:人工智能与新材料的发现

文章目录 总览人工智能正在革命性地发现新的或更强的材料&#xff0c;这将改变制造业。更坚韧的合金问题研究解决方案 新材料人工智能存在的挑战方法探索 日本的研究人员正在使用人工智能制造更强的金属合金或发现新材料&#xff0c;并彻底改变制造过程 总览 日本的研究人员开…...

鱼fish数据集VOC+yolo-1400张(labelImg标注)

鱼类&#xff0c;是最古老的脊椎动物。易蓄积重金属。 部分不同染色体数目的杂交的后代依然有生育能力。它们几乎栖居于地球上所有的水生环境&#xff0c;从淡水的湖泊、河流到咸水的大海和大洋。 今天要介绍鱼的数据集。 数据集名称&#xff1a;鱼 fish 数据集格式&#xf…...

爬虫解析-BeautifulSoup-bs4(七)

目录 1.bs4的安装 2.bs4的语法 &#xff08;1&#xff09;查找节点 &#xff08;2&#xff09;查找结点信息 3.bs4的操作 &#xff08;1&#xff09;对本地文件进行操作 &#xff08;2&#xff09;对服务器响应文件进行操作 4.实战 beautifulsoup&#xff1a;和lxml一样…...

分类预测 | Matlab实现OOA-SVM鱼鹰算法优化支持向量机的多变量输入数据分类预测

分类预测 | Matlab实现OOA-SVM鱼鹰算法优化支持向量机的多变量输入数据分类预测 目录 分类预测 | Matlab实现OOA-SVM鱼鹰算法优化支持向量机的多变量输入数据分类预测分类效果基本描述程序设计参考资料 分类效果 基本描述 1.Matlab实现OOA-SVM鱼鹰算法优化支持向量机的多变量输…...

2.vue学习笔记(目录结构+模板语法+属性绑定)

文章目录 1.目录结构2.模板语法2.1.文本插值2.2.使用JavaScript表达式2.3.原始HTML 3.属性绑定3.1.简写3.2.布尔型Attribute3.3.动态绑定多个值 1.目录结构 1.vscode ——VSCode工具的配置文件夹 2.node_modules ——Vue项目的运行依赖文件夹 3.public ——资源文件夹&am…...

Python基本语法及高级特性总结

1. Python基本语法 1.1 变量和数据类型 在Python中&#xff0c;变量不需要预先声明&#xff0c;可以直接赋值。Python是一种动态类型语言&#xff0c;变量的类型会根据赋值的对象自动确定。例如&#xff1a; a 10 # a是整数类型变量 b 3.14 # b是浮点数类型变量 c …...

03-详解网关的过滤器工厂和常见的网关过滤器路由过滤器,默认过滤器,全局过滤器的执行顺序

过滤器工厂 过滤器种类 GatewayFilter是网关中提供的一种过滤器,可以对进入网关的请求和微服务响应的结果做加工处理 Spring提供了31中不同的路由过滤器工厂 AddResponseHeader表示给请求添加响应头 default-filters: # 默认过滤器 - AddResponseHeaderX-Response-Default-R…...

基于SSM的小儿肺炎知识管理系统设计与实现

末尾获取源码 开发语言&#xff1a;Java Java开发工具&#xff1a;JDK1.8 后端框架&#xff1a;SSM 前端&#xff1a;Vue 数据库&#xff1a;MySQL5.7和Navicat管理工具结合 服务器&#xff1a;Tomcat8.5 开发软件&#xff1a;IDEA / Eclipse 是否Maven项目&#xff1a;是 目录…...

HuffMan tree

定义 给定N个权值作为N个叶子结点&#xff0c;构造一棵二叉树&#xff0c;若该树的带权路径长度达到最小&#xff0c;称这样的二叉树为最优二叉树&#xff0c;也称为哈夫曼树(Huffman Tree)。哈夫曼树是带权路径长度最短的树&#xff0c;权值较大的结点离根较近。 基础知识 路…...

各地加速“双碳”落地,数字能源供应商怎么选?

作者 | 曾响铃 文 | 响铃说 随着我国力争2030年前实现“碳达峰”、2060年前实现“碳中和”的“双碳”目标提出&#xff0c;为各地区、各行业的低碳转型和绿色可持续发展制定“倒计时”时间表&#xff0c;一场围绕“数字能源”、“智慧能源”、“新能源”等关键词的创新探索进…...

19.java绘图

A.Graphics类 Graphics类是java.awt包中的一个类&#xff0c;它用于在图形用户界面&#xff08;GUI&#xff09;或其他图形应用程序中进行绘制。该类通常与Component的paint方法一起使用&#xff0c;以在组件上进行绘制操作。 一些Graphics类的常见用法和方法&#xff1a; 在组…...

提升工作效率,尽在Microsoft Office LTSC 2021 for Mac!

在当今的办公环境中&#xff0c;高效率的工作是每个人都追求的目标。作为全球领先的办公软件套装&#xff0c;Microsoft Office LTSC 2021 for Mac将为您提供一站式的解决方案&#xff0c;帮助您轻松应对各种工作任务。 首先&#xff0c;Microsoft Office LTSC 2021 for Mac拥…...

day24_java的反射机制

反射 一、反射的概念 反射&#xff1a;加载类&#xff0c;反射出类的各个组成部分&#xff08;类的成员&#xff1a;构造方法&#xff0c;属性&#xff0c;方法&#xff09; java反射机制&#xff1a;在运行状态中&#xff0c;对于任何一个类都能够知道这个类的所有属性和方…...

VUE学习二、创建一个前端项目

1.创建一个vue项目 使用命令 vue ui启动vue脚手架 vue ui 等待项目创建好 可以来任务栏启动项目 参数那里可以设置启动端口等参数 启动成功 成功访问 2. 用webstorm 打开项目 脚手架页面可安装基本依赖 比如路由 使用ws打开项目 启动项目 npm run serve 3.修改启动…...

「红队笔记」靶机精讲:Prime1 - 信息收集和分析能力的试炼

「红队笔记」靶机精讲&#xff1a;Prime1 - 信息收集和分析能力的试炼 本文是作者在观看 B 站《红队笔记》后做的一些笔记及相关知识的补充。学渗透特别推荐大家去看。如有侵权&#xff0c;请联系作者&#xff0c;作者看到后会第一时间删除。 靶机精讲之Prime1&#xff0c;vu…...

JVM虚拟机系统性学习-对象的创建流程及对象的访问定位

对象的创建流程与内存分配 对象创建流程如下&#xff1a; Java 中新创建的对象如何分配空间呢&#xff1f; new 的对象先放 Eden 区&#xff08;如果是大对象&#xff0c;直接放入老年代&#xff09;当 Eden 区满了之后&#xff0c;程序还需要创建对象&#xff0c;则垃圾回收…...

perf与火焰图-性能分析工具

参考链接 perf性能分析工具使用分享 如何读懂火焰图&#xff1f;-阮一峰 perf基本用法-record,report-知乎 火焰图抓取 准备&#xff1a; centos安装perf工具 dnf install perf下载火焰图解析代码 git clone https://github.com/brendangregg/FlameGraph.git抓取指定进程…...

UniGui使用CSSUniTreeMenu滚动条

有些人反应UniTreeMenu当菜单项目比较多的时候会超出但是没有出滚动条&#xff0c;只需要添加如下CSS 老规矩&#xff0c;unitreemeu的layout的componentcls里添加bbtreemenu&#xff0c;然后在css里添加 .bbtreemenu .x-box-item{ overflow-y: auto; } 然后当内容超出后就会…...

Spring框架中的五种常用设计模式

1、单例模式 Spring 的 Bean 默认是单例模式&#xff0c;通过 Spring 容器管理 Bean 的⽣命周期&#xff0c;保证每个 Bean 只被 创建⼀次&#xff0c;并在整个应⽤程序中重用。 2.工厂模式 Spring 使⽤⼯⼚模式通过 BeanFactory 和 ApplicationContext 创建并管理 Bean 对象…...

华纳云:docker启动报错的原因和解决方法

Docker 启动报错可能由多种原因引起。以下是一些建议&#xff0c;可用于解决 Docker 启动问题&#xff1a; 查看 Docker 日志&#xff1a; 查看 Docker 的日志可以提供更多的详细信息&#xff0c;有助于定位问题。 sudo journalctl -xe | grep docker 或者查看 Docker 服务的详…...

代码规范及开发工具

代码规范及开发工具&#xff1a; 前端&#xff08;vscode、idea&#xff09;: JavaScript规范&#xff1a; 1. 谷歌开源项目风格指南&#xff1a;JavaScript 、TypeScript篇 https://zh-google-styleguide.readthedocs.io/en/latest/google-typescript-…...

证件照制作小程序源代码

17638103951(同v)...

自治调优!人大金仓解放DBA双手

数据库系统的性能是确保整个应用系统高效运转的关键因素&#xff0c;因此数据库性能调优工作至关重要。KingbaseES通过将人工调优过程内化为数据库内核&#xff0c;成功实现了自治调优。这种创新的调优方案为DBA提供了更高效且准确的性能调优途径&#xff0c;同时也显著降低了数…...