13.07.2015 Views

JSR 303 的参考实现使用指南 - JBoss

JSR 303 的参考实现使用指南 - JBoss

JSR 303 的参考实现使用指南 - JBoss

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

序 言数 据 校 验 是 任 何 一 个 应 用 程 序 都 会 用 到 的 功 能 , 无 论 是 显 示 层 还 是 持 久 层 . 通 常 , 相 同 的 校 验 逻 辑会 分 散 在 各 个 层 中 , 这 样 , 不 仅 浪 费 了 时 间 还 会 导 致 错 误 的 发 生 ( 译 注 : 重 复 代 码 ). 为 了 避 免 重复 , 开 发 人 员 经 常 会 把 这 些 校 验 逻 辑 直 接 写 在 领 域 模 型 里 面 , 但 是 这 样 又 把 领 域 模 型 代 码 和 校 验代 码 混 杂 在 了 一 起 , 而 这 些 校 验 逻 辑 更 应 该 是 描 述 领 域 模 型 的 元 数 据 .<strong>JSR</strong> <strong>303</strong> - Bean Validation - 为 实 体 验 证 定 义 了 元 数 据 模 型 和 API. 默 认 的 元 数 据 模 型 是 通 过Annotations 来 描 述 的 , 但 是 也 可 以 使 用 XML 来 重 载 或 者 扩 展 . Bean Validation API 并 不 局 限 于 应用 程 序 的 某 一 层 或 者 哪 种 编 程 模 型 , 例 如 , 如 图 所 示 , Bean Validation 可 以 被 用 在 任 何 一 层 , 或者 是 像 类 似 Swing 的 富 客 户 端 程 序 中 .Hibernate Validator is the reference implementation of this <strong>JSR</strong>. The implementationitself as well as the Bean Validation API and TCK are all provided and distributedunder the Apache Software License 2.0 [http://www.apache.org/licenses/LICENSE-2.0].v

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!