Grails [method]操作接受类型为[org…JSONObject]的参数,该参数未标记为@Validateable。
我有一个警告:Grails [method]操作接受类型为[org…JSONObject]的参数,该参数未标记为@Validateable。,grails,groovy,warnings,Grails,Groovy,Warnings,我有一个警告: Warning |The [addPeople] action accepts a parameter of type [org.codehaus.groovy.grails.web.json.JSONObject] which has not been marked with @Validateable. Data binding will still be applied to this command object but the instance will not be
Warning |The [addPeople] action accepts a parameter of type [org.codehaus.groovy.grails.web.json.JSONObject] which has not been marked with @Validateable. Data binding will still be applied to this command object but the instance will not be validateable.
def addPeople(JSONObject jsonsito) {
如果我将JSONObject更改为def,警告将消失。我确信引用是一个JSONObject。我这样做是为了避免将来的错误
任何人都可以解释我如何用@validable标记这个OBJ
提前谢谢
任何人都可以解释我如何用@validable标记这个OBJ
你不能。JSONObject
类不是代码的一部分,因此您无法将其设置为可验证的@validatable
当控制器操作在编译时接受参数时,Grails会为您生成一组代码。总之,生成的代码执行以下操作:
.validate()
作为旁注,如果参数类型是域类、
String
、8个基本类型之一或8个类型包装器之一,则上述过程不同。我上面描述的是系统在所有其他类型下的行为。我回答了问题,但作为旁注,我认为没有任何理由使用JSONObject
作为控制器操作的参数。谢谢Jeff。理解。