不工作在我的pom.xml文件中我有這些撂荒依賴也會添加@Valid Bean驗證的球衣
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-bean-validation</artifactId>
<version>2.25.1</version>
</dependency>
和延伸ResourceConfig
我CustomApplication類我已經註冊了這2個休耕性能
property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);
property(ServerProperties.BV_DISABLE_VALIDATE_ON_EXECUTABLE_OVERRIDE_CHECK, true);
我有一個DTO(POJO)這樣
import java.util.ArrayList;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.NotBlank;
public class PlotDTO {
private String guid;
@NotNull
private String plot_name;
@NotNull
private String farmer_id;
@NotNull
private float distance_from_warehouse;
@NotNull
private int area;
@NotNull
private float sand;
.............
.............
}
在我RESOUR CE類我試圖驗證此usingg @Valid
@Path("addplot")
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response addPlot(@Valid PlotDTO plot)
{
..............
..............
}
當我把這些@NotNull驗證請求沒有一個正在
能有人幫我這個
它適用於所有人還是僅僅是原始人? –
其中一些是必填字段。它與基元無關 –
我的觀點是基元不能爲空。 –