1
我有一个实体,它有几个带有JSR303注释约束的字段。我希望用户分几步设置这些字段。我认为具有显式绑定属性的视图状态可以完成这项工作。Spring Webflow状态下的部分JSR303组验证
我通过将LocalValidatorFactoryBean设置为<webflow:flow-builder-services … validator="flowValidator"/>
的验证器bean来启用JSR303验证。 hibernate-validator-5在类路径中。
@Configuration
@ImportResource("classpath:/flow.xml")
public class FlowConfiguration {
@Bean LocalValidatorFactoryBean flowValidator() {
return new LocalValidatorFactoryBean();
}
}
这并不是因为我需要这项工作。使用启用的验证程序,视图状态将验证完整的实体,由于存在@NotNull约束,因此会失败。虽然视图状态只有一个子集。
<view-state id="insertUser" view="registration/insertUser" model="vendor">
<binder>
<binding property="email" required="true" />
<binding property="name" required="true" />
</binder>
…
</view-state>
通过进一步阅读,我发现我正在谈论JSR-303组。是否有任何支持使用Spring Web Flow验证组?