【发布时间】:2018-05-10 07:59:34
【问题描述】:
我正在尝试使用 javax.validation.validation-api 来验证 @QueryParam 参数。我是jersey的新手,所以不太了解,请查看下面的代码
代码:
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{services/SuperWeb}")
@ValidateOnExecution
public String getBranchName(@PathParam("name") String name,
@NotNull @QueryParam("phone") String phone,
@NotNull @QueryParam("email") String email) {
try {
//Some code where I should not check the phone and email is not null...
} catch(Exception exception) {
throw new ...
}
return "";
}
Pom.xml
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-bean-validation</artifactId>
<version>2.12</version>
<exclusions>
<exclusion>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</exclusion>
</exclusions>
</dependency>
【问题讨论】:
-
我想我们在这里也有类似的问题。请在此处发布之前使用不同的搜索关键字。