如何在Play框架中的表单中设置int @Required?

时间:2014-01-08 16:26:20

标签: playframework playframework-2.2

我有一个传递给form()的课程:

public static class Creation {
        @Required(message = "Checkpoint name is required")
        public String name;

        @Required(message = "Longitude degrees are required")
        public double longitudeDegrees;

        @Required(message = "Longitude minutes are required")
        public double longitudeMinutes;

        @Required(message = "Latitude degrees are required")
        public double latitudeDegrees;

        @Required(message = "Latitude minutes are required")
        public double latitudeMinutes;

        @Required(message = "Message is required")
        public String message;

        @Required(message = "Points are required")  
        @Min(value= 1, message = "Points min. = 0")
        public int points;
}

当我提交表格时,积分字段为空,我在表单错误中得到error.invalid。如果我输入“0”,我会得到“Points min。= 0”错误。当字段为空时,我该怎么做才能获得“需要点数”消息?

1 个答案:

答案 0 :(得分:0)

我找到了答案。将字段类型intdouble更改为IntegerDouble