JSR 303 Bean验证+ Javascript客户端验证 [英] JSR 303 Bean Validation + Javascript Client-Side Validation

查看:191
本文介绍了JSR 303 Bean验证+ Javascript客户端验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在服务器端使用JSR 303 bean验证时,使用Javascript(最少代码重复)执行客户端表单验证的最佳方法是什么?我目前正在使用 Spring 3 Hibernate Validator

What is the best way to perform client-side form validation using Javascript (with minimal code duplication) when using JSR 303 bean validation on the server side? I'm currently using Spring 3 and the Hibernate Validator.

推荐答案

我找到了这个开源项目,但它看起来已经死了,也许它值得复活。

I found this open source project but it looks dead, maybe it is worth resurrecting.

http://kenai.com/ projects / jsr303js / pages / Home

此库提供基于JSR-303和Hibernate Validator注释的HTML表单的客户端验证,与Spring MVC集成。该库提供了一个JavaScript验证代码库,用于处理与HTML表单的基本交互,以及实现Hibernate Validator支持的验证注释的JavaScript函数(包括那些不是来自JSR-303规范的那些)。此JavaScript代码库可以通过使用提供的taglib或从jar中提取JavaScript文件并使用标记包含它来包含在页面中。将此代码库包含在页面中后,将使用第二个taglib生成用于验证HTML表单的JavaScript代码。您还可以在标记正文中提供JSON对象以指定其他配置信息。

This library provides client side validation of an HTML form based on JSR-303 and Hibernate Validator annotations, integrated with Spring MVC. The library provides a JavaScript validation code base that handles basic interaction with HTML forms, as well as JavaScript functions implementing the validation annotations supported by Hibernate Validator (including those not from the JSR-303 spec). This JavaScript code base can be included in a page by using a provided taglib or by extracting the JavaScript file from the jar and including it using a tag. Once this code base has been included in a page, a second taglib is used to generate the JavaScript code for validating an HTML form. You can also provide a JSON object in the body of the tag to specify additional configuration information.

这篇关于JSR 303 Bean验证+ Javascript客户端验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆