1 概述

如果遇到某些属性需要多种校验,比如需要非空、符合某正则表达式、长度不能超过某值等,如果这种属性只有有限几个,那么手工把对应的校验注解都加上即可。但如果这种属性比较多,那么重复加这些校验注解,也是一种代码重复。

hibernate-validator包提供了一种组合注解的方式,来解决上面场景的问题。

2 原理

2.1 例子

先来看一个组合校验注解的例子:

1) 定义一个新注解@FormatedString

import org.hibernate.validator.constraints.CompositionType;
import org.hibernate.validator.constraints.ConstraintComposition;import javax.validation.Constraint;
import javax.validation.OverridesAttribute;
import javax.validation.Payload;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE })
@Retention(RUNTIME)
@Documented
@ConstraintComposition(CompositionType.AND)
@NotEmpty
@Pattern(regexp = "")
@Size
@Constraint(validatedBy = {})
public @interface FormatedString {String message() default "{string.formated.message}";Class<?>[] groups() default { };Class<? extends Payload>[] payload() default { };@OverridesAttribute(constraint = Size.class, name = "min")int min() default 0;@OverridesAttribute(constraint = Size.class, name = "max")int max() default Integer.MAX_VALUE;@OverridesAttribute(constraint = Pattern.class, name = "regexp")String regexp() default "";
}

从上面看,@FormatedString注解的上方指定了非空(@NotEmpty)、正则表达式(@Pattern)、长度限制(@Size)这三个常用的的校验注解。@Constraint里面的validatedBy值为空,代表着自身没有提供ContraintValidator。@ConstraintComposition指定了多个注解校验结果的关系是AND,也就是都需要校验通过则总结果才算通过。

注意:使用@OverridesAttribute把参数传给原注解,这不属于Spring环境,不能使用Spring的@AliasFor来传参数。@Pattern的regexp属性没有给默认值,需要给一个默认值,否则无法通过编译。

2) 使用注解

// 以O开头且后面都是数字,长度在16-20之间
@FormatedString(regexp = "O[0-9]+", min = 16, max = 20)
private String orderNumber;

2.2 处理流程

详细的流程需要参考前面的文章,这里只给出涉及处理组合注解的部分。

// 源码位置:org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl
public ConstraintDescriptorImpl(ConstraintHelper constraintHelper,Constrainable constrainable,ConstraintAnnotationDescriptor<T> annotationDescriptor,ConstraintLocationKind constraintLocationKind,Class<?> implicitGroup,ConstraintOrigin definedOn,ConstraintType externalConstraintType) {this.annotationDescriptor = annotationDescriptor;this.constraintLocationKind = constraintLocationKind;this.definedOn = definedOn;this.isReportAsSingleInvalidConstraint = annotationDescriptor.getType().isAnnotationPresent(ReportAsSingleViolation.class);// 省略部分代码// 1. 当把校验注解的信息和属性封装为ConstraintDescriptorImpl时,还会解析一下校验注解里是否还带其它校验注解。//    annotationDescriptor为校验注解(如@NotNull),constrainable为属性字段信息(如标了@NotNull注解的mobilePhone属性字段),constraintType为GENERIC。//    返回结果赋值给了composingConstraints。this.composingConstraints = parseComposingConstraints( constraintHelper, constrainable, constraintType );this.compositionType = parseCompositionType( constraintHelper );validateComposingConstraintTypes();if ( constraintType == ConstraintType.GENERIC ) {this.matchingConstraintValidatorDescriptors = CollectionHelper.toImmutableList( genericValidatorDescriptors );}else {this.matchingConstraintValidatorDescriptors = CollectionHelper.toImmutableList( crossParameterValidatorDescriptors );}this.hashCode = annotationDescriptor.hashCode();
}// 源码位置:org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl
private Set<ConstraintDescriptorImpl<?>> parseComposingConstraints(ConstraintHelper constraintHelper, Constrainable constrainable, ConstraintType constraintType) {Set<ConstraintDescriptorImpl<?>> composingConstraintsSet = newLinkedHashSet();Map<ClassIndexWrapper, Map<String, Object>> overrideParameters = parseOverrideParameters();Map<Class<? extends Annotation>, ComposingConstraintAnnotationLocation> composingConstraintLocations = new HashMap<>();// 2. annotationDescriptor为校验注解(如@NotNull),从注解上获取标注的其它注解for ( Annotation declaredAnnotation : this.annotationDescriptor.getType().getDeclaredAnnotations() ) {Class<? extends Annotation> declaredAnnotationType = declaredAnnotation.annotationType();// 3. NON_COMPOSING_CONSTRAINT_ANNOTATIONS为@Target、@Retention等常用注解,它们与校验无关,过滤掉if ( NON_COMPOSING_CONSTRAINT_ANNOTATIONS.contains( declaredAnnotationType.getName() ) ) {continue;}// 4. 判断注解是否为校验注解,内置的注解和加了@Constraint的注解才是校验注解if ( constraintHelper.isConstraintAnnotation( declaredAnnotationType ) ) {if ( composingConstraintLocations.containsKey( declaredAnnotationType )&& !ComposingConstraintAnnotationLocation.DIRECT.equals( composingConstraintLocations.get( declaredAnnotationType ) ) ) {throw LOG.getCannotMixDirectAnnotationAndListContainerOnComposedConstraintException( annotationDescriptor.getType(), declaredAnnotationType );}// 5. 为每个校验注解也生成一个ConstraintDescriptorImplConstraintDescriptorImpl<?> descriptor = createComposingConstraintDescriptor(constraintHelper,constrainable,overrideParameters,OVERRIDES_PARAMETER_DEFAULT_INDEX,declaredAnnotation,constraintType);// 6. 生成的ConstraintDescriptorImpl,放到composingConstraintsSet里面,该Set座位返回值赋值给了this.composingConstraintscomposingConstraintsSet.add( descriptor );composingConstraintLocations.put( declaredAnnotationType, ComposingConstraintAnnotationLocation.DIRECT );LOG.debugf( "Adding composing constraint: %s.", descriptor );}else if ( constraintHelper.isMultiValueConstraint( declaredAnnotationType ) ) {List<Annotation> multiValueConstraints = constraintHelper.getConstraintsFromMultiValueConstraint( declaredAnnotation );int index = 0;for ( Annotation constraintAnnotation : multiValueConstraints ) {if ( composingConstraintLocations.containsKey( constraintAnnotation.annotationType() )&& !ComposingConstraintAnnotationLocation.IN_CONTAINER.equals( composingConstraintLocations.get( constraintAnnotation.annotationType() ) ) ) {throw LOG.getCannotMixDirectAnnotationAndListContainerOnComposedConstraintException( annotationDescriptor.getType(),constraintAnnotation.annotationType() );}ConstraintDescriptorImpl<?> descriptor = createComposingConstraintDescriptor(constraintHelper,constrainable,overrideParameters,index,constraintAnnotation,constraintType);composingConstraintsSet.add( descriptor );composingConstraintLocations.put( constraintAnnotation.annotationType(), ComposingConstraintAnnotationLocation.IN_CONTAINER );LOG.debugf( "Adding composing constraint: %s.", descriptor );index++;}}}return CollectionHelper.toImmutableSet( composingConstraintsSet );
}
private static final List<String> NON_COMPOSING_CONSTRAINT_ANNOTATIONS = Arrays.asList(Documented.class.getName(),Retention.class.getName(),Target.class.getName(),Constraint.class.getName(),ReportAsSingleViolation.class.getName(),Repeatable.class.getName(),Deprecated.class.getName()
);// 源码位置:org.hibernate.validator.internal.metadata.core.MetaConstraint
MetaConstraint(ConstraintValidatorManager constraintValidatorManager, ConstraintDescriptorImpl<A> constraintDescriptor,ConstraintLocation location, List<ContainerClassTypeParameterAndExtractor> valueExtractionPath,Type validatedValueType) {// 7. 在把找到的校验注解(如@NotNull)和属性字段封装为MetaConstraint时,要确定ConstraintTree的实际实现类,//    ConstraintTree的实现有两种,一种是对应单个校验注解的SimpleConstraintTree,另外一种是对应多个校验注解的ComposingConstraintTreethis.constraintTree = ConstraintTree.of( constraintValidatorManager, constraintDescriptor, validatedValueType );this.location = location;this.valueExtractionPath = getValueExtractionPath( valueExtractionPath );this.hashCode = buildHashCode( constraintDescriptor, location );this.isDefinedForOneGroupOnly = constraintDescriptor.getGroups().size() <= 1;
}// 源码位置:org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree
public static <U extends Annotation> ConstraintTree<U> of(ConstraintValidatorManager constraintValidatorManager,ConstraintDescriptorImpl<U> composingDescriptor, Type validatedValueType) {// 8. composingDescriptor.getComposingConstraintImpls()获取到的就是上面的composingConstraints//    当校验注解上还加了其它校验注解,则composingConstraints不为空,//    composingConstraints为空则创建的是SimpleConstraintTree,否则创建的是ComposingConstraintTreeif ( composingDescriptor.getComposingConstraintImpls().isEmpty() ) {return new SimpleConstraintTree<>( constraintValidatorManager, composingDescriptor, validatedValueType );}else {return new ComposingConstraintTree<>( constraintValidatorManager, composingDescriptor, validatedValueType );}
}
// 源码位置:org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl
public Set<ConstraintDescriptorImpl<?>> getComposingConstraintImpls() {return composingConstraints;
}// 实际校验的时候会调ConstraintTree的validateConstraints()方法,ComposingConstraintTree重载了父类ConstraintTree的validateConstraints()方法
// 源码位置:org.hibernate.validator.internal.engine.constraintvalidation.ComposingConstraintTree
protected void validateConstraints(ValidationContext<?> validationContext,ValueContext<?, ?> valueContext,Collection<ConstraintValidatorContextImpl> violatedConstraintValidatorContexts) {// 9. 校验CompositionResult compositionResult = validateComposingConstraints(validationContext, valueContext, violatedConstraintValidatorContexts);Optional<ConstraintValidatorContextImpl> violatedLocalConstraintValidatorContext;if ( mainConstraintNeedsEvaluation( validationContext, violatedConstraintValidatorContexts ) ) {if ( LOG.isTraceEnabled() ) {LOG.tracef("Validating value %s against constraint defined by %s.",valueContext.getCurrentValidatedValue(),descriptor);}ConstraintValidator<B, ?> validator = getInitializedConstraintValidator( validationContext, valueContext );ConstraintValidatorContextImpl constraintValidatorContext = validationContext.createConstraintValidatorContextFor(descriptor, valueContext.getPropertyPath());violatedLocalConstraintValidatorContext = validateSingleConstraint(valueContext,constraintValidatorContext,validator);if ( !violatedLocalConstraintValidatorContext.isPresent() ) {compositionResult.setAtLeastOneTrue( true );}else {compositionResult.setAllTrue( false );}}else {violatedLocalConstraintValidatorContext = Optional.empty();}if ( !passesCompositionTypeRequirement( violatedConstraintValidatorContexts, compositionResult ) ) {prepareFinalConstraintViolations(validationContext, valueContext, violatedConstraintValidatorContexts, violatedLocalConstraintValidatorContext);}
}// 源码位置:org.hibernate.validator.internal.engine.constraintvalidation.ComposingConstraintTree
private CompositionResult validateComposingConstraints(ValidationContext<?> validationContext,ValueContext<?, ?> valueContext,Collection<ConstraintValidatorContextImpl> violatedConstraintValidatorContexts) {CompositionResult compositionResult = new CompositionResult( true, false );// 10. 当校验注解上还加了其它校验注解,其它校验注解每个也对应生成了一个处理单个校验注解的SimpleConstraintTree//     children就是SimpleConstraintTree列表for ( ConstraintTree<?> tree : children ) {List<ConstraintValidatorContextImpl> tmpConstraintValidatorContexts = new ArrayList<>( 5 );// 11. 把注解当一个普通的校验注解完成校验逻辑tree.validateConstraints( validationContext, valueContext, tmpConstraintValidatorContexts );violatedConstraintValidatorContexts.addAll( tmpConstraintValidatorContexts );if ( tmpConstraintValidatorContexts.isEmpty() ) {compositionResult.setAtLeastOneTrue( true );if ( descriptor.getCompositionType() == OR ) {break;}}else {compositionResult.setAllTrue( false );if ( descriptor.getCompositionType() == AND&& ( validationContext.isFailFastModeEnabled() || descriptor.isReportAsSingleViolation() ) ) {break;}}}return compositionResult;
}// 回到ComposingConstraintTree的validateConstraints继续处理
// 源码位置:org.hibernate.validator.internal.engine.constraintvalidation.ComposingConstraintTree
protected void validateConstraints(ValidationContext<?> validationContext,ValueContext<?, ?> valueContext,Collection<ConstraintValidatorContextImpl> violatedConstraintValidatorContexts) {// 9. 校验CompositionResult compositionResult = validateComposingConstraints(validationContext, valueContext, violatedConstraintValidatorContexts);Optional<ConstraintValidatorContextImpl> violatedLocalConstraintValidatorContext;// 12. 如果校验注解本身也指定了校验器,那么它本身也需要当一个普通校验注解进行校验if ( mainConstraintNeedsEvaluation( validationContext, violatedConstraintValidatorContexts ) ) {if ( LOG.isTraceEnabled() ) {LOG.tracef("Validating value %s against constraint defined by %s.",valueContext.getCurrentValidatedValue(),descriptor);}ConstraintValidator<B, ?> validator = getInitializedConstraintValidator( validationContext, valueContext );ConstraintValidatorContextImpl constraintValidatorContext = validationContext.createConstraintValidatorContextFor(descriptor, valueContext.getPropertyPath());violatedLocalConstraintValidatorContext = validateSingleConstraint(valueContext,constraintValidatorContext,validator);if ( !violatedLocalConstraintValidatorContext.isPresent() ) {compositionResult.setAtLeastOneTrue( true );}else {compositionResult.setAllTrue( false );}}else {violatedLocalConstraintValidatorContext = Optional.empty();}// 13. 有多个校验结果的时候,需要确定一下总结果是什么if ( !passesCompositionTypeRequirement( violatedConstraintValidatorContexts, compositionResult ) ) {prepareFinalConstraintViolations(validationContext, valueContext, violatedConstraintValidatorContexts, violatedLocalConstraintValidatorContext);}
}// 源码位置:org.hibernate.validator.internal.engine.constraintvalidation.ComposingConstraintTree
private boolean passesCompositionTypeRequirement(Collection<?> constraintViolations, CompositionResult compositionResult) {// 14. 有三种关系:一是OR,只要有一个校验通过即可;二是AND,需要所有都校验通过;三是ALL_FALSE,所有校验都不通过。//     如果不指定CompositionType,那么默认是ANDCompositionType compositionType = getDescriptor().getCompositionType();boolean passedValidation = false;switch ( compositionType ) {case OR:passedValidation = compositionResult.isAtLeastOneTrue();break;case AND:passedValidation = compositionResult.isAllTrue();break;case ALL_FALSE:passedValidation = !compositionResult.isAtLeastOneTrue();break;}assert ( !passedValidation || !( compositionType == AND ) || constraintViolations.isEmpty() );if ( passedValidation ) {constraintViolations.clear();}return passedValidation;
}

在找校验注解的时候,把关联的注解也当普通的校验注解处理(封装到ConstraintDescriptorImpl对象里),处理结果放到一个Set中。在校验的时候,先处理这个Set的内容,处理流程和普通的校验注解一样;处理完之后再处理当前校验注解本身,处理流程和普通的校验注解一样。

由此可以看出,在设计的时候,不管是内置的校验注解,还是自定义的校验注解,原理都是一致的,只有初始化的地方不一样;同样,组合校验注解也会分解成当前注解和关联的校验注解,分解之后也是普通的注解,也是在初始化的时候和校验开始时分解的地方不一样,其它的都是一样的。这个组合的设计思路值得学习。

3 架构一小步

针对需要一起组合使用的校验注解,利用hibernate-validator包提供的组合机制自定义一个新校验注解把它们组合起来,方便使用。

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

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

相关文章

网络基础19:OSPF多区域实验

一、拓扑结构1. 网络拓扑&#xff1a;骨干区域&#xff08;Area 0&#xff09;&#xff1a;连接核心设备&#xff08;AR1、AR2、AR3、AR4、AR5、AR6&#xff09;。非骨干区域&#xff1a;Area 1&#xff1a;AR5 ↔ AR9Area 2&#xff1a;AR5 ↔ AR10Area 3&#xff1a;AR6 ↔ A…

goland编写go语言导入自定义包出现: package xxx is not in GOROOT (/xxx/xxx) 的解决方案

问题 写了个自定义的包 calc.go&#xff0c;在路径 $GOPATH/go_project/src/demo_51_package/com/目录下&#xff0c;其中main.go 是main方法的入口代码 main.go 代码如下 package main import "demo_51_package/com" func main() {add : calc.Add(1, 2)println(add)…

HLS视频切片音频中断问题分析与解决方案

HLS视频切片音频中断问题分析与解决方案 问题背景 在使用FFmpeg进行HLS视频切片并通过hls.js前端播放时&#xff0c;开发者经常遇到一个典型问题&#xff1a;第一个视频切片播放正常且有声音&#xff0c;但后续切片却突然失去音频。这种现象在直播和点播场景中均有出现&#xf…

【Linux网络编程】网络层协议 - IP

目录 背景补充 协议头格式 IP报文的分片与组装 网段划分 网段划分是什么&#xff1f;为什么要进行网段划分&#xff1f; 怎么进行网段划分&#xff1f; 路由 路由表生成算法 背景补充 假设现在主机B要给主机C发送消息。在我们前面的学习中&#xff0c;一直都是将数据拷…

从“救火”到“先知”:润建曲尺运维大模型如何重构网络运维价值链

“7月18号&#xff0c;北京&#xff0c;晴&#xff0c;最高温度38摄氏度。”天气预报缓缓播报&#xff0c;商场、地铁、办公楼无不歌颂着威利斯开利的贡献&#xff0c;但这份凉爽的背后&#xff0c;离不开 “电” 的无声托举。5G毫秒级下载、丝滑的移动支付、智能电表、智能家居…

Element表格单元格类名动态设置

在 Element UI 的 el-table 组件中&#xff0c;cell-class-name 属性用于动态自定义表格单元格的 CSS 类名&#xff0c;通常用于根据数据条件设置样式。1. 基本用法在 el-table 上绑定 :cell-class-name 属性&#xff0c;值为一个函数。该函数接收一个对象参数&#xff0c;返回…

利用容器适配器实现stack和queue外加deque的介绍(STL)

文章目录前言什么是容器适配器&#xff1f;观察库中的源码那么该如何使用容器适配器呢&#xff1f;deque的简单介绍(了解)deque的原理介绍deque的优缺为什么选择deque作为stack和queue的底层默认容器&#xff1f;&#xff08;重点&#xff09;利用容器适配器实现我们自己的栈和…

【因子动物园巡礼】第12章:机器学习在因子投资中的应用(中文翻译)

【因子动物园巡礼】第12章&#xff1a;机器学习在因子投资中的应用&#xff08;中文翻译&#xff09;第12章 因子投资中的机器学习12.1 量化金融中的人工智能12.2 量化因子投资的AI化组件&#xff1a;解剖学视角12.2.1 数据源拓展与预处理12.2.2 因子研究12.2.3 因子模型12.2.4…

【Golang】用官方rate包构造简单IP限流器

文章目录使用 Go 实现基于 IP 地址的限流机制什么是 IP 限流&#xff1f;基于 rate.Limiter 实现 IP 限流1. 设计思路2. 代码实现3. 限流中间件4. 在 Gin 中使用中间件代码解释使用 Go 实现基于 IP 地址的限流机制 在高流量的服务中&#xff0c;限流是一个至关重要的环节。它不…

力扣 Pandas 挑战(6)---数据合并

本文围绕力扣的Pandas简单题集&#xff0c;解析如何用Pandas完成基础数据处理任务&#xff0c;适合Pandas初学者学习。题目1&#xff1a;1050. 合作过至少三次的演员和导演题目描述&#xff1a;ActorDirector 表&#xff1a;---------------------- | Column Name | Type | …

随笔之TDengine基准测试示例

文章目录一、基本信息二、基准测试策略三、基准测试过程1. 模拟高并发写入场景2. 模拟并发查询场景四、基准测试结论一、基本信息 TDengine 版本&#xff1a;3.3.6.13&#xff08;目前最新版本&#xff09;服务器配置&#xff1a;16核CPU&#xff0c;32GB内存&#xff0c;高IO…

【IQA技术专题】DISTS代码讲解

本文是对DISTS图像质量评价指标的代码解读&#xff0c;原文解读请看DISTS文章讲解。 本文的代码来源于IQA-Pytorch工程。 1、原文概要 以前的一些IQA方法对于捕捉纹理上的感知一致性有所欠缺&#xff0c;鲁棒性不足。基于此&#xff0c;作者开发了一个能够在图像结构和图像纹…

2024年SEVC SCI2区,一致性虚拟领航者跟踪群集算法GDRRT*-PSO+多无人机路径规划,深度解析+性能实测

目录1.摘要2.算法背景3.GDRRT*-PSO与虚拟领航者跟踪算法4.结果展示5.参考文献6.算法辅导应用定制读者交流1.摘要 随着无人机技术的快速发展及其卓越的运动和机动性能&#xff0c;无人机在社会和军事等诸多领域得到了广泛应用。多无人机协同作业&#xff0c;能够显著提升任务执…

链特异性文库是什么?为什么它在转录组测序中越来越重要?

链特异性文库是什么&#xff1f;为什么它在转录组测序中越来越重要&#xff1f; 在现代分子生物学研究中&#xff0c;RNA测序&#xff08;RNA-seq&#xff09; 是一种广泛应用的技术&#xff0c;用于分析基因在不同条件下的表达情况。而在RNA-seq的众多技术细节中&#xff0c;有…

ClickHouse vs PostgreSQL:数据分析领域的王者之争,谁更胜一筹?

文章概要 作为一名数据架构师&#xff0c;我经常被问到一个问题&#xff1a;在众多数据库选择中&#xff0c;ClickHouse和PostgreSQL哪一个更适合我的项目&#xff1f;本文将深入探讨这两种数据库系统的核心差异、性能对比、适用场景以及各自的优缺点&#xff0c;帮助您在技术选…

面向对象系统的单元测试层次

面向对象系统的单元测试层次面向对象&#xff08;Object-Oriented, OO&#xff09;编程范式引入了封装、继承和多态等核心概念&#xff0c;这使得传统的、基于函数的单元测试方法不再充分。面向对象系统的单元测试必须适应其独特的结构和行为特性&#xff0c;从单一方法扩展到类…

如何用USRP捕获手机信号波形(上)系统及知识准备

目录&#xff1a; 如何用USRP捕获手机信号波形&#xff08;上&#xff09;系统及知识准备 如何用USRP捕获手机信号波形&#xff08;中&#xff09;手机/基站通信 如何用USRP捕获手机信号波形&#xff08;下&#xff09;协议分析 一、手机通信参数获取 首先用Cellular-z网络…

C语言-数组:数组(定义、初始化、元素的访问、遍历)内存和内存地址、数组的查找算法和排序算法;

本章概述思维导图&#xff1a;C语言数组在C语言中&#xff0c;数组是一种固定大小的、相同类型元素的有序集合&#xff0c;通过索引&#xff08;下标&#xff09;访问。数组数组&#xff1a;是一种容器&#xff0c;可以用来存储同种数据类型的多个值&#xff1b;数组特点&#…

河南萌新联赛2025第(二)场:河南农业大学(补题)

文章目录前言A.约数个数和整除分块(相当于约数求和)相关例题&#xff1a;取模B.异或期望的秘密二进制的规律相关例题累加器小蓝的二进制询问乘法逆元1. 概念2.基本定义3.费马小定理1.定理内容2.重要推论D.开罗尔网络的备用连接方案E.咕咕嘎嘎!!!(easy)I.猜数游戏(easy)K.打瓦M.…

常见中间件漏洞

一、TomcatTomcat put方法任意文件写入漏洞环境搭建&#xff0c;启动时端口被占用就改yml配置文件&#xff0c;改成8081端口。(我这里是8080)cd vulhub-master/tomcat/CVE-2017-12615 docker-compose up -d 去抓包&#xff0c;改成put提交。下面的内容是用哥斯拉生成的木马文件…