【发布时间】:2013-04-16 20:52:40
【问题描述】:
我正在为 JAX-RS 使用 Jersey 实现,我正在寻找一个可以在 POST 申请中使用 Bean Validation 的示例。我有这个操作,例如:
@POST
@Path("document/annotations/save")
@Produces("application/json")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Map<String, Object> saveAnnotation(
@FormParam("user") String userStr,
@FormParam("documentId") String documentId,
@FormParam("documentPage") Integer documentPage,
@FormParam("annotationContent") String annotationContent,
@FormParam("annotationId") Long annotationId,
@FormParam("isMobile") Boolean isMobile) { // the code... }
我想为每个方法参数使用验证约束(@NotNull、@Pattern 等)。我看到了doc,他们正在使用 Seam 框架来做到这一点。
目前,我正在尝试使用 javax.validation 实现来验证我的请求,但它不起作用。
有没有办法将 JSR-303 规范与 JAX-RS 一起使用?
Tnks。
【问题讨论】:
-
像
AspectJ这样使用aop怎么样?
标签: validation http jersey jax-rs