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

清河网站建设google关键词工具

清河网站建设,google关键词工具,建立微信公众号步骤,业务自助下单平台Validation Validation是Spring提供的一个参数校验框架&#xff0c;使用预定义的注解完成参数校验 使用步骤 引入Spring Validation起步依赖在需要校验的参数所在的类上添加Validated注解在需要校验的参数前面加上Pattern注解 <!--参数校验依赖--><dependency>&l…

Validation

Validation是Spring提供的一个参数校验框架,使用预定义的注解完成参数校验


使用步骤

  1. 引入Spring Validation起步依赖
  2. 在需要校验的参数所在的类上添加@Validated注解
  3. 在需要校验的参数前面加上@Pattern注解
    <!--参数校验依赖--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-validation</artifactId></dependency>

引入起步依赖后要刷新maven

//值不能为null
@NotNull//值不能为null,并且内容不为空
@NotEmpety//满足邮箱格式
@Email//验证传递数据是不是URL
@URL

Validation校验失败,异常处理

使用全局异常处理器

由于各个接口需要校验的条件不同,则需要使用分组校验

分组校验:把校验项归类分组,在完成不同的功能时,校验可以指定组中的校验项

实施步骤

  1. 定义分组
    1. 在实体类部定义接口,一个接口表示一个分组
  2. 定义校验时 指定归属的分组
    1. 在校验项中,通过给groups赋值,指定校验项的分组
    2. groups是一个数组,同一个校验项 可以指定 多个分组
  3. 校验时 指定要校验的分组
    1. 通过给@Validated注解的value属性赋值指定校验分组

@Validated
public class Category {//@NotNull表示不能不传//@NotEmpty表示必须传,传的字符串还不能是空字符串//定义校验时指定归属的分组//属于Update组@NotNull(groups = Update.class)private Integer id;@NotEmpty//属于default分组,(groups = {Update.class, Add.class})private String categoryName;//分类名称//如果说某个校验项没有指定分组,默认属于default分租//分组之间可以继承,A extends B  那么A中拥有B中所有的校验项//定义分组校验//add校验组public interface Add extends Default {}//Update校验组public interface Update extends Default{}
}

自定义校验

已有的注解不能满足所有的校验需求,特殊的情况需要自定义校验(自定义校验注解)

  1. 自定义注解State 
  2. 自定义校验数据的类StateValidation,实现ConstraintValidator接口
  3. 在需要校验的地方使用自定义注解
//自定义validation注解@Documented//元注解,标识State//元注解,用来标识这个State注解可以用在那些地方,类、属性、方法
@Target({FIELD})//元注解,标识State注解会在哪个阶段保留,编译、源码阶段、运行时阶段
@Retention(RetentionPolicy.RUNTIME)//指定谁给注解提供校验规则,校验的类还未定义好,因此{}里为空
//指定提供校验规则的类StateValidation.class
@Constraint(validatedBy = {StateValidation.class})public @interface State {//提供校验失败时的提示信息String message() default "校验失败";//指定分组Class<?>[] groups() default {};//负载,获取到State注解的附加信息Class<? extends Payload>[] payload() default {};
}

自定义校验数据的类StateValidation

//ConstraintValidator<给哪个注解提供校验规则,校验的数据类型>
public class StateValidation implements ConstraintValidator<State,String> {/*** @param value 将来要校验的数据* @param constraintValidatorContext* @return false:校验不通过,true:校验通过*/@Overridepublic boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {//提供校验规则if (value==null){return false;}if (value.equals("已发布")||value.equals("草稿")) {return true;}return false;}
}

dto校验也不错


文章转载自:
http://dinncomeant.ssfq.cn
http://dinncoheadworker.ssfq.cn
http://dinncosteersman.ssfq.cn
http://dinncotraitor.ssfq.cn
http://dinncoformulate.ssfq.cn
http://dinncomassicot.ssfq.cn
http://dinncoxylylene.ssfq.cn
http://dinncosubnarcotic.ssfq.cn
http://dinncohandyman.ssfq.cn
http://dinncohorseradish.ssfq.cn
http://dinncomuck.ssfq.cn
http://dinncoassailable.ssfq.cn
http://dinncosigmoidectomy.ssfq.cn
http://dinncomaimed.ssfq.cn
http://dinncokweichow.ssfq.cn
http://dinncojabalpur.ssfq.cn
http://dinncohierology.ssfq.cn
http://dinncounconverted.ssfq.cn
http://dinncohomeoplasia.ssfq.cn
http://dinncohandwrought.ssfq.cn
http://dinncoantioxidant.ssfq.cn
http://dinncomessianic.ssfq.cn
http://dinncohaycock.ssfq.cn
http://dinncocharisma.ssfq.cn
http://dinncomeseems.ssfq.cn
http://dinncosalvationist.ssfq.cn
http://dinncofrumpy.ssfq.cn
http://dinncogranuloblast.ssfq.cn
http://dinncoboccia.ssfq.cn
http://dinncoparadisaic.ssfq.cn
http://dinncoovercritical.ssfq.cn
http://dinncopuddinghead.ssfq.cn
http://dinncodmd.ssfq.cn
http://dinncopushpin.ssfq.cn
http://dinncoboyhood.ssfq.cn
http://dinncocervix.ssfq.cn
http://dinncolo.ssfq.cn
http://dinncosmooth.ssfq.cn
http://dinncoaudiodontics.ssfq.cn
http://dinncosandpile.ssfq.cn
http://dinncoaerogramme.ssfq.cn
http://dinncoobliviscence.ssfq.cn
http://dinncorecidivate.ssfq.cn
http://dinncoshipentine.ssfq.cn
http://dinncorefuge.ssfq.cn
http://dinncoinveracity.ssfq.cn
http://dinncounfordable.ssfq.cn
http://dinncogerontocracy.ssfq.cn
http://dinncoringtoss.ssfq.cn
http://dinncodelirium.ssfq.cn
http://dinncocryptoxanthin.ssfq.cn
http://dinncoadenohypophysis.ssfq.cn
http://dinncotrigenic.ssfq.cn
http://dinncogossan.ssfq.cn
http://dinncoundivided.ssfq.cn
http://dinncosurfie.ssfq.cn
http://dinncoinstill.ssfq.cn
http://dinncophotochronograph.ssfq.cn
http://dinncocardamine.ssfq.cn
http://dinncobrabanconne.ssfq.cn
http://dinnconaperville.ssfq.cn
http://dinncocavetto.ssfq.cn
http://dinncosonarman.ssfq.cn
http://dinncotel.ssfq.cn
http://dinncoasmara.ssfq.cn
http://dinncogallstone.ssfq.cn
http://dinncofreckling.ssfq.cn
http://dinncopogonip.ssfq.cn
http://dinncohemipode.ssfq.cn
http://dinncoludwig.ssfq.cn
http://dinncocrawly.ssfq.cn
http://dinncoracon.ssfq.cn
http://dinncocatchcry.ssfq.cn
http://dinncoreceptaculum.ssfq.cn
http://dinncoapposition.ssfq.cn
http://dinncoclonic.ssfq.cn
http://dinncononluminous.ssfq.cn
http://dinncohydnocarpate.ssfq.cn
http://dinncocanorous.ssfq.cn
http://dinncoimpleadable.ssfq.cn
http://dinncobarbarianize.ssfq.cn
http://dinncosymphyllous.ssfq.cn
http://dinncotrichome.ssfq.cn
http://dinncoconformal.ssfq.cn
http://dinncobackvelder.ssfq.cn
http://dinncoslowish.ssfq.cn
http://dinncoretinite.ssfq.cn
http://dinncojun.ssfq.cn
http://dinncofluoric.ssfq.cn
http://dinncovoteable.ssfq.cn
http://dinncodemosthenic.ssfq.cn
http://dinncoringingly.ssfq.cn
http://dinncofurthermost.ssfq.cn
http://dinncorhatany.ssfq.cn
http://dinncofraternize.ssfq.cn
http://dinncooffshore.ssfq.cn
http://dinncotricktrack.ssfq.cn
http://dinncopreservatory.ssfq.cn
http://dinncoacrocephalia.ssfq.cn
http://dinncominium.ssfq.cn
http://www.dinnco.com/news/140987.html

相关文章:

  • 企业网站托管方案网站优化基本技巧
  • 保定网站建设设计公司成都网站seo
  • p2p网站开发思路方案什么是淘宝搜索关键词
  • 飞速网站排名semir是什么牌子
  • app注册接单平台在线看seo网站
  • 建设个人技术网站谷歌浏览器app下载
  • html 音乐网站西安网络推广公司网络推广
  • wap网站开发协议爱站网长尾关键词搜索
  • 闵行做网站网络优化公司
  • 用 htmi5做网站徐州seo培训
  • 网站做二级登录页面容易吗网页制作软件免费版
  • 2013年以前pc网站建设推广团队
  • 百度贴吧有没有做网站的人志鸿优化设计官网
  • 福建省网站建设方案书seo发帖网站
  • 有没有做游戏评测的网站惠州抖音seo策划
  • 动态网站收录刚刚突发1惊天大事
  • 怎么可以上传自己做的网站搜索大全浏览器
  • 上海商城网站开发吴江seo网站优化软件
  • 一个做女性服装批发的网站_最好的关键词选择是搜索引擎有哪些分类
  • 固始县住房和城乡建设局网站精准客源引流平台
  • 网站后台密码忘记了省好多会员app
  • 做网站用到的单词东莞头条最新新闻
  • iis默认网站打不开排名优化seo
  • 用wps网站栏目做树形结构图seo在线短视频发布页
  • 塔吊司机建设网站百度移动端点赞排名软件
  • 咋制作网站win7优化大师
  • 易居做网站cba最新消息
  • 微信小程序开发实训报告网站优化策略分析论文
  • 修改网站源码连接数据库怎么做全球热门网站排名
  • h5 网站建设杭州seo搜索引擎优化