Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Vaadin 7密码字段正则表达式验证不工作_Java_Regex_Vaadin_Vaadin7 - Fatal编程技术网

Java Vaadin 7密码字段正则表达式验证不工作

Java Vaadin 7密码字段正则表达式验证不工作,java,regex,vaadin,vaadin7,Java,Regex,Vaadin,Vaadin7,对于工作正常的标准Java正则表达式,如下所示:- Pattern pattern = Pattern.compile("\\s"); Matcher matcher = pattern.matcher("space here"); Matcher matcher2 = pattern.matcher("noSpaceHere"); boolean foundSpace = matcher.find();

对于工作正常的标准Java正则表达式,如下所示:-

    Pattern pattern = Pattern.compile("\\s");
    Matcher matcher = pattern.matcher("space here");
    Matcher matcher2 = pattern.matcher("noSpaceHere");
    boolean foundSpace = matcher.find();
    boolean noSpace = matcher.find();
    System.out.println("Space found "+foundSpace);
    System.out.println("Any space found "+noSpace);
我想瓦丁也是这样。但它不起作用:

PasswordField field = new PasswordField((String) processConfig.get("name"));
field.setWidth("100%");
field.addValidator(new RegexpValidator("\\s", "Whitespace is not allowed for password field"));
截图:-


无论我给这个PasswordField输入什么,它总是报告无效。在本例中,我将abcd作为输入。我的意图是不允许密码字段有任何空格。如何为Vaadin PasswordField执行此操作?

请尝试允许0-n除空格以外的任何其他字符的regexpt:

field.addValidator(new RegexpValidator("[^\\s]*", "Whitespace is not allowed for password field"));