grails - 浮动的最小/最大约束失败?
grails - min / max constraints fail for float?
我有这个class:
class SomeClass {
float percent
static constraints = {
percent(min:1.0F, max:100.0F)
}
}
当我启动应用程序时出现错误:
Parameter for constraint [min] of property [percent] of class [class SomeClass] must be the same type as property: [float]
这是错误还是我做错了什么?
我认为你应该使用小 f
而不是 F
:
static constraints = {
percent(min:1.0f, max:100.0f)
}
或
尝试将 percent
的类型更改为 Float
,然后 1.0F 应该有效
我有这个class:
class SomeClass {
float percent
static constraints = {
percent(min:1.0F, max:100.0F)
}
}
当我启动应用程序时出现错误:
Parameter for constraint [min] of property [percent] of class [class SomeClass] must be the same type as property: [float]
这是错误还是我做错了什么?
我认为你应该使用小 f
而不是 F
:
static constraints = {
percent(min:1.0f, max:100.0f)
}
或
尝试将 percent
的类型更改为 Float
,然后 1.0F 应该有效