Struts 2验证w /注释获取空异常 [英] Struts 2 Validation w/ annotations getting a null exception
问题描述
我们正在尝试使用Struts 2 Validation w / Annotations,我们遇到了一个奇怪的问题。我们有一个方法,我们已经指定了一个字符串验证。当我们运行该方法时,我们在第580行的AnnotationValidationConfigurationBuilder中得到一个NullException。我们看了看,验证Factory为null。我们追溯到后面,并且找不到为什么它将为null的原因,尽管我们注意到setValidatorFactory上的@Inject注释。
作为附注,我们也在组合中使用Spring 2,并从jQuery插件中调用它。
<有人有人遇到过吗?我们已经查看了所有的文档,没有人谈到需要使用Spring注册一个bean或者这样的东西。
谢谢,
Shane
我们找到了答案。显然,如果您有一个validators.xml,则需要指定base validators.xml中的所有内容。自从我们过去使用这个以来,这种情况已经改变了,而不需要这样做。
We're trying to use Struts 2 Validation w/ Annotations and we've ran into a weird problem. We have a method that we have specified a string validation for. When we run that method we get a NullException in the AnnotationValidationConfigurationBuilder on line 580. We took a look and it appears that the validationFactory is null. We traced that back and can't find a reason why it would be null though we did notice an @Inject annotation on the setValidatorFactory.
As a side note we're also using Spring 2 in the mix and calling it from the jQuery plugin.
Has anyone run into this before? We've looked at all the docs and none of them talk about needing to register a bean with Spring or anything like that.
Thanks,
Shane
We found the answer. Apparently if you have a validators.xml you need to specify everything in the base validators.xml. This has changed since we used this in the past without needing to do this.
这篇关于Struts 2验证w /注释获取空异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!