太阳集团tyc5997|官网【中国】有限公司

java正则表达式判断前端参数修改表中另一个字段
  • 作者:admin
  • 发表时间:2021-01-05 07:53
  • 来源:未知

本文主要介绍java正则表达式判断前端参数修改表中另一个字段的值,有需要的朋友可以参考

前端传输参数并调用接口

将两个值发送到后端,比较它们,满足条件,并修改数据表中另一个字段的值

init (id) {

this.dataForm.id=id || 0

this.visible=true

这个。$nextTick(()={

这个。$refs['dataForm']。resetFields()

if (this.dataForm.id) {

这个。$http({

Url :this。$ http . adol nurl(`/这里是接口/${this.dataForm.id} `)、

method: 'get ',

参数:这个。$ http.adornParams()

}).然后(({data})={

if (data data.code===0) {

//将这两个值传递到后端

this . data form . now year=data . sys . now year

this . data form . nowyearstatus=data . sys . nowyearstatus

}

})

Nb唐山网站设计sp;}

})

},

后端代码

public int updateById(Sysentity Sysentity){

//在要验证的字符串的前端接收的参数

string str=Sysentity . GetNowyear();

//正则表达式规则汉字

string regex='^[\\u4e00-\\u9fa5]{0,}$';

//正则表达式正则整数或小数

String regExNum='^[0-9] \\。{0,1}[0-9]{0,2}$';

//编译正则表达式

pattern pattern=pattern.compile(RegEx);

pattern pattern num=pattern.compile(RegExnum);

matcher matcher=pattern . matcher(str);

matcher matcherNum=patternNum . matcher(str);

//查找字符串中是否有与正则表达式匹配的字符/字符串

布尔RS=matcher . find();

boolean RSNum=MatcherNum . find();

if (rs==true) {

//是否上升,1高于,0小于,2等于

//判断条件满足,修改IfRise的值

systargetentity . setifrise(' 2 ');

}

if (rsNum==true) {

//与目标值相比,目标值为1

//比较两个接收到的参数

int result=Sysentity . GetNowYearStatus()。compare to(Sysentity . GetNowyear());

if (result0) {

//是否上升,1高于,0小于,2等于

sysentity . setifrise(' 1 ');

} else if (result0){

sysentity . setifrise(' 0 ');

} else if (result==0) {

sysentity . setifrise(' 2 ');

}

}

返回this . basemapper . updatebyids(sysTargetEntity);

}

规则性

整数或小数:[0-9] \。{0,1} [0-9] {0,2} $

只能输入数字:“[0-9] * $”。

只能输入n位数字:“\ d {n} $”。

您只能输入至少n位数字:“\ d {n,} $”。

只能输入m~n位数字:'^\d{m,n}$'

Baidu
sogou