| |

VerySource

 Forgot password?
 Register
Search
View: 771|Reply: 2

Regarding the issue of dynamic verification of Struts, please advise on regular expressions

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-3-6 09:30:01
| Show all posts |Read mode
I want to verify Chinese in the jsp text box, here are the settings of the relevant parts in my jsp and validate.xml:
input.jsp:

<html: text name = "userInfoForm" property = "searchuserid" size = "24" maxlength = "20" />

validate.xml

            <field property = "searchuserid" depends = "mask">
<arg key = "maintenanceUserForm.searchuserid" resource = "true" />
<msg name = "mask" key = "errors.maintenanceuser.userid.type" />
<var>
<var-name> mask </ var-name>
<var-value> ^ [\u4e00-\u9fa5] * $ </ var-value>
</ var>
            </ field>

As a result, the Chinese language has not been verified. What is verified is: u, 4, e, 0,9, f, a, 5. What is going on?
I wrote a java program to verify Chinese ^ [\u4e00-\u9fa5] * $ This regular expression is correct. Why is it difficult to use it in the dynamic verification framework of struts?

I also experimented with <var-value> ^ [0-9] * $ </ var-value> to verify the number
However, <var-value> ^ [\u0030-\u0039] * $ </ var-value> Except for 0-9, even a-z and A-Z can pass the verification. What is the reason for this?

public static void main (String [] args) {
String str = "1";
String regEx = "^ [\u0030-\u0039] * $";
Pattern p = Pattern.compile (regEx);
Matcher m = p.matcher (str);
boolean result = m.find ();
System.out.println (result);
}
Is easy to use.
Reply

Use magic Report

0

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-5-29 15:30:02
| Show all posts
I have not checked Chinese when using Struts
How about adding a group ^ ([\u4e00-\u9fa5] *) $
good luck
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-8-7 14:45:02
| Show all posts
The .xml file does not support UNICODE.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list