我在我的项目中使用Oval验证,我想在rest api中验证参数。但是Oval是一个对象验证框架,我知道它可以验证java对象,但是如何验证oval的queryparam和pathparam呢?
我有一个rest api,如下:
@Get
public Response get(@QueryParam("id") String id) {
return Response.ok().build();
}当我添加注解@NotNull String id时,似乎oval不是有效的参数。有没有人知道如何验证参数id?
发布于 2016-09-09 19:31:41
验证方法参数需要字节码增强或使用代理对象。
为此,您可以使用OVal的基于AspectJ的契约编程特性,请参阅http://oval.sourceforge.net/userguide.html#programming-by-contract
如果您的应用程序使用Spring管理的服务,您还可以使用Spring集成来实现服务方法参数验证,请参阅http://oval.sourceforge.net/userguide.html#spring-integration。可以在SpringAOPAllianceBeanValidationTest上找到一个示例
https://stackoverflow.com/questions/36770318
复制相似问题