我收到了这个警告:
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) {
如果我为def更改JSONObject,则警告消失。我确信引用是一个JSONObject。我这样做是为了避免将来的PermGem错误。
任何人都可以解释我如何用@Validateable标记这个OBJ?
提前致谢。
答案 0 :(得分:4)
任何人都可以解释我如何用@Validateable标记这个OBJ?
你不能。 JSONObject
课程不属于您的代码,因此您无法将其设为@Validateable
。
当控制器动作在编译时接受参数时,Grails会为您生成一堆代码。总之,生成的代码执行以下操作:
@Validateable
,则调用.validate()
步骤4是有条件的,只有在对象为@Validateable
时才会发生。在你的情况下它不会,这很好。警告只是让你知道。
作为旁注,如果参数类型是域类String
,8种基本类型之一或8种类型包装之一,则上述过程是不同的。我上面描述的是系统对所有其他类型的行为。