|
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. |
|