shiro 整合 springmvc 实战及源码详解

序言

前面我们学习了如下内容:

5 分钟入门 shiro 安全框架实战笔记

shiro 整合 spring 实战及源码详解

相信大家对于 shiro 已经有了最基本的认识,这一节我们一起来学习写如何将 shiro 与 springmvc 进行整合。

spring mvc 整合源码

maven 依赖

  • 版本号
<properties><jetty.version>9.4.34.v20201102</jetty.version><shiro.version>1.7.0</shiro.version><spring.version>5.2.8.RELEASE</spring.version><taglibs.standard.version>1.2.5</taglibs.standard.version>
</properties>
  • shiro 相关依赖
<dependency><groupId>org.apache.shiro</groupId><artifactId>shiro-core</artifactId><version>${shiro.version}</version>
</dependency>
<dependency><groupId>org.apache.shiro</groupId><artifactId>shiro-spring</artifactId><version>${shiro.version}</version>
</dependency>
<dependency><groupId>org.apache.shiro</groupId><artifactId>shiro-web</artifactId><version>${shiro.version}</version>
</dependency>
  • 其他依赖

主要是 servlet、spring、数据库和 tags

<dependency><groupId>javax.annotation</groupId><artifactId>javax.annotation-api</artifactId><version>1.3.2</version>
</dependency>
<dependency><groupId>javax.servlet</groupId><artifactId>javax.servlet-api</artifactId><version>3.1.0</version><scope>provided</scope>
</dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-context</artifactId><version>${spring.version}</version>
</dependency>
<dependency><groupId>org.springframework</groupId><artifactId>spring-jdbc</artifactId><version>${spring.version}</version>
</dependency>
<dependency><groupId>org.springframework</groupId><artifactId>spring-webmvc</artifactId><version>${spring.version}</version>
</dependency><dependency><groupId>org.hsqldb</groupId><artifactId>hsqldb</artifactId><version>2.5.0</version><scope>runtime</scope>
</dependency><dependency><groupId>org.apache.taglibs</groupId><artifactId>taglibs-standard-spec</artifactId><version>${taglibs.standard.version}</version><scope>runtime</scope>
</dependency>
<dependency><groupId>org.apache.taglibs</groupId><artifactId>taglibs-standard-impl</artifactId><version>${taglibs.standard.version}</version><scope>runtime</scope>
</dependency>
  • jetty

依赖于 jetty 作为容器启动:

<plugin><groupId>org.eclipse.jetty</groupId><artifactId>jetty-maven-plugin</artifactId><version>${jetty.version}</version><configuration><httpConnector><port>8080</port></httpConnector><webApp><contextPath>/</contextPath></webApp></configuration>
</plugin>

配置

  • applicaiton.properties

主要指定了 shiro 相关的配置

# Let Shiro Manage the sessions
shiro.userNativeSessionManager = true# disable URL session rewriting
shiro.sessionManager.sessionIdUrlRewritingEnabled = false
# 登录地址
shiro.loginUrl = /s/login
# 登录成功
shiro.successUrl = /s/index
# 未授权
shiro.unauthorizedUrl = /s/unauthorized

LoginController 登录控制器

我们首先来看一下后端的登录控制器:

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;/*** Spring MVC controller responsible for authenticating the user.** @since 0.1*/
@Component
@RequestMapping("/s/login")
public class LoginController {private static transient final Logger log = LoggerFactory.getLogger(LoginController.class);private static String loginView = "login";@RequestMapping(method = RequestMethod.GET)protected String view() {return loginView;}@RequestMapping(method = RequestMethod.POST)protected String onSubmit(@RequestParam("username") String username,@RequestParam("password") String password,Model model) throws Exception {UsernamePasswordToken token = new UsernamePasswordToken(username, password);try {SecurityUtils.getSubject().login(token);} catch (AuthenticationException e) {log.debug("Error authenticating.", e);model.addAttribute("errorInvalidLogin", "The username or password was not correct.");return loginView;}return "redirect:/s/index";}
}

登录的校验非常简单,直接根据页面的账户密码,然后执行登录校验。

LogoutController 登出控制器

登出直接调用对应的 logout 方法,并且重定向到登录页面。

import org.apache.shiro.SecurityUtils;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;/*** Controller responsible for logging out the current user by invoking* {@link org.apache.shiro.subject.Subject#logout()}** @since 0.1*/
@Component
@RequestMapping("/s/logout")
public class LogoutController extends AbstractController {@RequestMapping(method = RequestMethod.GET)protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {SecurityUtils.getSubject().logout();return new ModelAndView("redirect:login");}
}

核心组件

当然,上面的实现看起来非常简单。

数据准备

实际上还有一些用户的账户密码信息准备,是直接通过 BootstrapDataPopulator 类实现的,将账户信息存储到内存数据库 hsqldb 中。

SaltAwareJdbcRealm

针对领域信息的获取实现如下:

import org.apache.shiro.authc.*;
import org.apache.shiro.realm.jdbc.JdbcRealm;
import org.apache.shiro.util.ByteSource;
import org.apache.shiro.util.JdbcUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;/*** Realm that exists to support salted credentials.  The JdbcRealm implementation needs to be updated in a future* Shiro release to handle this.*/
public class SaltAwareJdbcRealm extends JdbcRealm {private static final Logger log = LoggerFactory.getLogger(SaltAwareJdbcRealm.class);@Overrideprotected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {UsernamePasswordToken upToken = (UsernamePasswordToken) token;String username = upToken.getUsername();// Null username is invalidif (username == null) {throw new AccountException("Null usernames are not allowed by this realm.");}Connection conn = null;AuthenticationInfo info = null;try {conn = dataSource.getConnection();String password = getPasswordForUser(conn, username);if (password == null) {throw new UnknownAccountException("No account found for user [" + username + "]");}SimpleAuthenticationInfo saInfo = new SimpleAuthenticationInfo(username, password, getName());/*** This (very bad) example uses the username as the salt in this sample app.  DON'T DO THIS IN A REAL APP!** Salts should not be based on anything that a user could enter (attackers can exploit this).  Instead* they should ideally be cryptographically-strong randomly generated numbers.*/saInfo.setCredentialsSalt(ByteSource.Util.bytes(username));info = saInfo;} catch (SQLException e) {final String message = "There was a SQL error while authenticating user [" + username + "]";if (log.isErrorEnabled()) {log.error(message, e);}// Rethrow any SQL errors as an authentication exceptionthrow new AuthenticationException(message, e);} finally {JdbcUtils.closeConnection(conn);}return info;}private String getPasswordForUser(Connection conn, String username) throws SQLException {PreparedStatement ps = null;ResultSet rs = null;String password = null;try {ps = conn.prepareStatement(authenticationQuery);ps.setString(1, username);// Execute queryrs = ps.executeQuery();// Loop over results - although we are only expecting one result, since usernames should be uniqueboolean foundResult = false;while (rs.next()) {// Check to ensure only one row is processedif (foundResult) {throw new AuthenticationException("More than one user row found for user [" + username + "]. Usernames must be unique.");}password = rs.getString(1);foundResult = true;}} finally {JdbcUtils.closeResultSet(rs);JdbcUtils.closeStatement(ps);}return password;}}

这里直接通过默认的 sql

select password from users where username = ?

获取账户信息,然后进行最简单的加密验证。

web.xml 配置

细心的小伙伴也许发现了,这个 mvc 项目中没有 web.xml 文件。

那么,一般需要指定的配置是如何指定的呢?

官方给出的案例有另外一个配置类实现了这个功能。

import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.filter.DelegatingFilterProxy;
import org.springframework.web.servlet.DispatcherServlet;import javax.servlet.DispatcherType;
import javax.servlet.FilterRegistration;
import javax.servlet.ServletContext;
import javax.servlet.ServletRegistration;
import java.util.EnumSet;/*** Initializes Spring Environment without the need for a web.xml*/
public class ServletApplicationInitializer implements WebApplicationInitializer {@Overridepublic void onStartup(ServletContext container) {//now add the annotationsAnnotationConfigWebApplicationContext appContext = getContext();// Manage the lifecycle of the root application contextcontainer.addListener(new ContextLoaderListener(appContext));FilterRegistration.Dynamic shiroFilter = container.addFilter("shiroFilterFactoryBean", DelegatingFilterProxy.class);shiroFilter.setInitParameter("targetFilterLifecycle", "true");shiroFilter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false, "/*");ServletRegistration.Dynamic remotingDispatcher = container.addServlet("remoting", new DispatcherServlet(appContext));remotingDispatcher.setLoadOnStartup(1);remotingDispatcher.addMapping("/remoting/*");ServletRegistration.Dynamic dispatcher = container.addServlet("DispatcherServlet", new DispatcherServlet(appContext));dispatcher.setLoadOnStartup(1);dispatcher.addMapping("/");}private AnnotationConfigWebApplicationContext getContext() {AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();context.setConfigLocation(getClass().getPackage().getName());return context;}}

授权方法

当然,不同的用户登录的权限不同,肯定是因为我们定义了不同的权限。

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;/*** Business manager interface used for sample application.** @since 0.1*/
public interface SampleManager {/*** Method that requires <tt>role1</tt> in order to be invoked.*/@RequiresRoles("role1")void secureMethod1();/*** Method that requires <tt>role2</tt> in order to be invoked.*/@RequiresRoles("role2")void secureMethod2();/*** Method that requires <tt>permission1</tt> in order to be invoked.*/@RequiresPermissions("permission2")void secureMethod3();
}

这里通过 @RequiresRoles@RequiresPermissions 指定了方法访问需要的角色或者权限。

实战效果

为了便于大家学习,上述代码已经全部开源:

https://github.com/houbb/shiro-inaction/tree/master/shiro-inaction-02-springmvc

登录页面

启动程序,浏览器直接访问 http://localhost:8080/,会被重定向到登录页面。

登录

user1 登录

我们使用 user1 登录:

user1 登录

user2 登录

我们使用 user2 登录:

user2 登录

登出

直接点击页面的登出链接,就可以实现登出。

实现原理

思考

现在,老马和大家一起思考一个问题。

我们在 application.properties 文件中指定了对应的登录/登出路径,那么 shiro 是如何映射并且执行的呢?

答案就是 Filter。

针对每一个请求,shiro 会判断请求的 url 是否和我们指定的 url 匹配,并且调用对应的 filter,然后出发对应的方法。

实际上 shiro 中有很多内置的 filter 实现,我们选取其中的几个做下介绍。

登录验证 Filter

匿名

最简单的就是所有的用户都可以访问,实现也最简单:

import org.apache.shiro.web.filter.PathMatchingFilter;import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;* @since 0.9*/
public class AnonymousFilter extends PathMatchingFilter {/*** Always returns <code>true</code> allowing unchecked access to the underlying path or resource.** @return <code>true</code> always, allowing unchecked access to the underlying path or resource.*/@Overrideprotected boolean onPreHandle(ServletRequest request, ServletResponse response, Object mappedValue) {// Always return true since we allow access to anyonereturn true;}}

这种适合登录页面之类的,比如可以指定如下

/user/signup/** = anon

form 表单提交

还有比较常用的就是 form 表单提交,springboot 整合的时候甚至可以省略掉我们写的登录校验实现。

/*** <p>If you would prefer to handle the authentication validation and login in your own code, consider using the* {@link PassThruAuthenticationFilter} instead, which allows requests to the* {@link #loginUrl} to pass through to your application's code directly.** @see PassThruAuthenticationFilter* @since 0.9*/
public class FormAuthenticationFilter extends AuthenticatingFilter {//TODO - complete JavaDocpublic static final String DEFAULT_ERROR_KEY_ATTRIBUTE_NAME = "shiroLoginFailure";public static final String DEFAULT_USERNAME_PARAM = "username";public static final String DEFAULT_PASSWORD_PARAM = "password";public static final String DEFAULT_REMEMBER_ME_PARAM = "rememberMe";private static final Logger log = LoggerFactory.getLogger(FormAuthenticationFilter.class);private String usernameParam = DEFAULT_USERNAME_PARAM;private String passwordParam = DEFAULT_PASSWORD_PARAM;private String rememberMeParam = DEFAULT_REMEMBER_ME_PARAM;private String failureKeyAttribute = DEFAULT_ERROR_KEY_ATTRIBUTE_NAME;public FormAuthenticationFilter() {setLoginUrl(DEFAULT_LOGIN_URL);}@Overridepublic void setLoginUrl(String loginUrl) {String previous = getLoginUrl();if (previous != null) {this.appliedPaths.remove(previous);}super.setLoginUrl(loginUrl);if (log.isTraceEnabled()) {log.trace("Adding login url to applied paths.");}this.appliedPaths.put(getLoginUrl(), null);}//...
}

当然可以有很多种方式,主要就是构建出登录的账户密码信息。

这里继承自 AuthenticatingFilter 实现类,会调用对应的登录方法:

protected boolean executeLogin(ServletRequest request, ServletResponse response) throws Exception {AuthenticationToken token = createToken(request, response);if (token == null) {String msg = "createToken method implementation returned null. A valid non-null AuthenticationToken " +"must be created in order to execute a login attempt.";throw new IllegalStateException(msg);}try {Subject subject = getSubject(request, response);subject.login(token);return onLoginSuccess(token, subject, request, response);} catch (AuthenticationException e) {return onLoginFailure(token, e, request, response);}
}

登出验证 Filter

shiro 也为我们实现了内置的登出过滤器。

/*** Simple Filter that, upon receiving a request, will immediately log-out the currently executing* {@link #getSubject(javax.servlet.ServletRequest, javax.servlet.ServletResponse) subject}* and then redirect them to a configured {@link #getRedirectUrl() redirectUrl}.** @since 1.2*/
public class LogoutFilter extends AdviceFilter {//.../*** Acquires the currently executing {@link #getSubject(javax.servlet.ServletRequest, javax.servlet.ServletResponse) subject},* a potentially Subject or request-specific* {@link #getRedirectUrl(javax.servlet.ServletRequest, javax.servlet.ServletResponse, org.apache.shiro.subject.Subject) redirectUrl},* and redirects the end-user to that redirect url.** @param request  the incoming ServletRequest* @param response the outgoing ServletResponse* @return {@code false} always as typically no further interaction should be done after user logout.* @throws Exception if there is any error.*/@Overrideprotected boolean preHandle(ServletRequest request, ServletResponse response) throws Exception {// 获取主题信息Subject subject = getSubject(request, response);// 检测是否只支持 POST 方式登出// Check if POST only logout is enabledif (isPostOnlyLogout()) {// check if the current request's method is a POST, if not redirectif (!WebUtils.toHttp(request).getMethod().toUpperCase(Locale.ENGLISH).equals("POST")) {// 返回对应的非 post 登出的响应return onLogoutRequestNotAPost(request, response);}}// 获取重定向的地址String redirectUrl = getRedirectUrl(request, response, subject);//try/catch added for SHIRO-298:try {// 执行登出方法subject.logout();} catch (SessionException ise) {log.debug("Encountered session exception during logout.  This can generally safely be ignored.", ise);}issueRedirect(request, response, redirectUrl);return false;}//...
}

授权验证 Filter

RolesAuthorizationFilter 角色授权过滤器

import java.io.IOException;
import java.util.Set;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;import org.apache.shiro.subject.Subject;
import org.apache.shiro.util.CollectionUtils;/*** Filter that allows access if the current user has the roles specified by the mapped value, or denies access* if the user does not have all of the roles specified.** @since 0.9*/
public class RolesAuthorizationFilter extends AuthorizationFilter {//TODO - complete JavaDoc@SuppressWarnings({"unchecked"})public boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) throws IOException {// 获取当前主题Subject subject = getSubject(request, response);// 获取需要的角色列表String[] rolesArray = (String[]) mappedValue;if (rolesArray == null || rolesArray.length == 0) {//no roles specified, so nothing to check - allow access.return true;}// 判断是否拥有指定的角色Set<String> roles = CollectionUtils.asSet(rolesArray);return subject.hasAllRoles(roles);}}

PermissionsAuthorizationFilter 权限授权过滤器

import java.io.IOException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;import org.apache.shiro.subject.Subject;/*** Filter that allows access if the current user has the permissions specified by the mapped value, or denies access* if the user does not have all of the permissions specified.** @since 0.9*/
public class PermissionsAuthorizationFilter extends AuthorizationFilter {public boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) throws IOException {// 获取主题Subject subject = getSubject(request, response);// 需要的权限String[] perms = (String[]) mappedValue;boolean isPermitted = true;if (perms != null && perms.length > 0) {if (perms.length == 1) {// 如果列表长度为1,进行校验if (!subject.isPermitted(perms[0])) {isPermitted = false;}} else {// 如果需要多个,执行校验if (!subject.isPermittedAll(perms)) {isPermitted = false;}}}return isPermitted;}
}

小结

这一节我们讲解了如何整合 springmvc 与 shiro,可以发现 shiro 内置了非常多的实现,帮助我们简化登录的设计实现。

不过使用过 springboot 的小伙伴都知道,我们的实现可以变得更加简化。

可以阅读 springboot 与 shiro 的整合:

shiro 整合 springboot 实战笔记

希望本文对你有所帮助,如果喜欢,欢迎点赞收藏转发一波。

我是老马,期待与你的下次相遇。

参考资料

10 Minute Tutorial on Apache Shiro

https://shiro.apache.org/reference.html

https://shiro.apache.org/session-management.html

本文由博客一文多发平台 OpenWrite 发布!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/698031.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

水务界的“数字蝶变”:水务公司重构自我,开启智慧供水新时代

历经六十余载的稳健前行&#xff0c;某水务公司已发展成为国有一档企业中的供水行业佼佼者&#xff0c;不仅主营业务突出&#xff0c;更拥有完善的产业链条。然而&#xff0c;面对供水业务24小时连续作业的高要求&#xff0c;以及业务管理需求的日益复杂化&#xff0c;公司意识…

【Django开发】0到1开发美多shop项目:Celery短信和用户注册。全md文档笔记(附代码,已分享)

本系列文章md笔记&#xff08;已分享&#xff09;主要讨论django商城项目开发相关知识。本项目利用Django框架开发一套前后端不分离的商城项目&#xff08;4.0版本&#xff09;含代码和文档。功能包括前后端不分离&#xff0c;方便SEO。采用Django Jinja2模板引擎 Vue.js实现…

网页403错误(Spring Security报异常 Encoded password does not look like BCrypt)

这个错误通常表现为"403 Forbidden"或"HTTP Status 403"&#xff0c;它指的是访问资源被服务器理解但拒绝授权。换句话说&#xff0c;服务器可以理解你请求看到的页面&#xff0c;但它拒绝给你权限。 也就是说很可能测试给定的参数有问题&#xff0c;后端…

学习Redis基础篇

1.初识Redis 1.认识NoSQL 2.认识Redis 3.连接redis命令 4.数据结构的介绍 5.通用命令 2.数据类型 1.String类型 常见命令&#xff1a;例子&#xff1a;set key value

Vue3实现页面顶部进度条

Vue3页面增加进度条 新建进度条组件新建bar.ts导航守卫中使用 Vue3项目使用导航守卫给页面增加进度条 新建进度条组件 loadingBar.vue <template><div class"wraps"><div ref"bar" class"bar"></div></div> <…

VSCODE上使用python_Django_创建最小项目

接上篇 https://blog.csdn.net/weixin_44741835/article/details/136135996?csdn_share_tail%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22136135996%22%2C%22source%22%3A%22weixin_44741835%22%7D VSCODE官网&#xff1a; Editing Python …

精酿啤酒:麦芽与啤酒花搭配的奥秘

麦芽和啤酒花是啤酒酿造过程中不可或缺的原料&#xff0c;它们的风味和特点对啤酒的口感和品质产生着深远的影响。Fendi Club啤酒在麦芽与啤酒花的搭配方面有着与众不同的技巧和见解&#xff0c;让啤酒的口感更加丰富和迷人。 首先&#xff0c;麦芽的选择是啤酒酿造的关键之一。…

【目标检测新SOTA!v7 v4作者新作!】YOLO v9 思路复现 + 全流程优化

YOLO v9 思路复现 全流程优化 提出背景&#xff1a;深层网络的 信息丢失、梯度流偏差YOLO v9 设计逻辑可编程梯度信息&#xff08;PGI&#xff09;&#xff1a;使用PGI改善训练过程广义高效层聚合网络&#xff08;GELAN&#xff09;&#xff1a;使用GELAN改进架构 对比其他解法…

精通Django模板(模板语法、继承、融合与Jinja2语法的应用指南)

模板&#xff1a; 基础知识&#xff1a; ​ 在Django框架中&#xff0c;模板是可以帮助开发者快速⽣成呈现给⽤户⻚⾯的⼯具模板的设计⽅式实现了我们MVT中VT的解耦(M: Model, V:View, T:Template)&#xff0c;VT有着N:M的关系&#xff0c;⼀个V可以调⽤任意T&#xff0c;⼀个…

百度地图海量点方案趟坑记录(百度地图GL版 + MapVGL + vue3 + ts)

核心需求描述 不同层级有不同的海量图标展示底层海量图标需要展示文字拖动、放大缩小都需要重新请求数据并展示固定地图中心点&#xff08;拖动、放大缩小&#xff0c;中心点始终在地图中心&#xff09; 示例图片&#xff1a;&#xff08;某些图片涉及公司数据&#xff0c;就未…

基础数据结构和算法《》

递归 1.递归应该一种比较常见的实现一些特殊代码逻辑时需要做的&#xff0c;但常常也是最绕的一种方式&#xff0c;在解释递归 之前&#xff0c;我们用循环和递归来做个比较1.1.如果你打开一扇门后&#xff0c;同样发现前方也有一扇们&#xff0c;紧接着你又打开下一扇门...直…

备战蓝桥杯---基础算法刷题1

最近在忙学校官网上的题&#xff0c;就借此记录分享一下有价值的题&#xff1a; 1.注意枚举角度 如果我们就对于不同的k常规的枚举&#xff0c;复杂度直接炸了。 于是我们考虑换一个角度&#xff0c;我们不妨从1开始枚举因子&#xff0c;我们记录下他的倍数的个数sum个&#…

Android platform tool中d8.bat不生效

d8.bat因找不到java_exe文件&#xff0c;触发EOF d8.bat中之前代码为&#xff1a; set java_exe if exist "%~dp0..\tools\lib\find_java.bat" call "%~dp0..\tools\lib\find_java.bat" if exist "%~dp0..\..\tools\lib\find_java.bat" …

分享一个我爱工具网源码优化版

应用介绍 本文来自&#xff1a;分享一个我爱工具网源码优化版 - 源码1688 前几天在网上看到了一个不错的工具网源码&#xff0c;但是源码存在一些问题&#xff0c;遂进行了修改优化。 主要修改内容有&#xff1a; 1、后台改为账号密码登录&#xff0c;上传即用&#xff0c;不…

前后端延迟怎么解决

当今互联网应用的发展越来越迅猛&#xff0c;用户对于网站或应用的性能要求也越来越高。其中一个重要方面就是前后端延迟的解决&#xff0c;也就是减少前端与后端之间的通信时间延迟&#xff0c;提高用户体验。本文将详细介绍如何解决前后端延迟的问题。 网络延迟 数据在网络…

【DAY03 软考中级备考笔记】存储系统,总线系统,输入输出系统和可靠性

存储系统&#xff0c;总线系统&#xff0c;输入输出系统和可靠性 2月22日 – 天气&#xff1a;阴转晴 济南下大雪&#xff0c;居家办公两天。 1. 计算机存储器的分类 根据存储位置划分&#xff1a; 内存/主存&#xff1a;用来保存当前正在运行的程序所需要的数据&#xff0c…

【C++精简版回顾】6.构造函数

一。类的四种初始化方式 1.不使用构造函数初始化类 使用函数引用来初始化类 class MM { public:string& getname() {return name;}int& getage() {return age;}void print() {cout << "name: " << name << endl << "age: &quo…

React学习——快速上手

文章目录 初步模块思维 初步 https://php.cn/faq/400956.html 1、可以手动使用npm来安装各种插件&#xff0c;来从头到尾自己搭建环境。 如&#xff1a; npm install react react-dom --save npm install babel babel-loader babel-core babel-preset-es2015 babel-preset-rea…

3.测试教程 - 基础篇

文章目录 软件测试的生命周期软件测试&软件开发生命周期如何描述一个bug如何定义bug的级别bug的生命周期如何开始第一次测试测试的执行和BUG管理产生争执怎么办&#xff08;处理人际关系&#xff09; 大家好&#xff0c;我是晓星航。今天为大家带来的是 测试基础 相关的讲解…

防火墙内容安全笔记

目录 DFI和DPI IDS和IPS 签名 AV URL过滤 HTTPS过滤 内容过滤 文件类型过滤 文件内容过滤 邮件过滤 VPN概述 密码学概述 对称加密 非对称加密 DFI和DPI DFI和DPI技术 --- 深度检测技术 DPI DPI --- 深度包检测技术 --- 主要针对完整的数据包&#xff08;数据包…