[method] 操作接受类型为 [org...JSONObject] 的参数,该参数未使用 @Validateable 标记。
The [method] action accepts a parameter of type [org...JSONObject] which has not been marked with @Validateable.
我收到此警告:
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。我这样做是为了避免将来出现 PermGem 错误。
任何人都可以解释我如何用@Validateable 标记这个 OBJ?
提前致谢。
Anyone can explain how can I mark with @Validateable this OBJ?
你不能。 JSONObject
class 不是您代码的一部分,因此您无法实现 @Validateable
.
当控制器操作在编译时接受参数时,Grails 会为您生成一堆代码。总之,生成的代码执行以下操作:
- 创建参数为
实例的class实例
- 使实例受数据绑定
- 对实例进行依赖注入
- 如果实例是
@Validateable
,则调用 .validate()
- 然后你在方法中的代码终于被执行了
第 4 步是有条件的,只有当对象是 @Validateable
时才会发生。在你的情况下它不会,这很好。警告只是让你知道。
附带说明一下,如果参数类型是域 class、String
、8 种基本类型之一或 8 种类型包装器之一,则上述过程会有所不同。我上面描述的是系统对所有其他类型的行为方式。
我收到此警告:
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。我这样做是为了避免将来出现 PermGem 错误。
任何人都可以解释我如何用@Validateable 标记这个 OBJ?
提前致谢。
Anyone can explain how can I mark with @Validateable this OBJ?
你不能。 JSONObject
class 不是您代码的一部分,因此您无法实现 @Validateable
.
当控制器操作在编译时接受参数时,Grails 会为您生成一堆代码。总之,生成的代码执行以下操作:
- 创建参数为 实例的class实例
- 使实例受数据绑定
- 对实例进行依赖注入
- 如果实例是
@Validateable
,则调用.validate()
- 然后你在方法中的代码终于被执行了
第 4 步是有条件的,只有当对象是 @Validateable
时才会发生。在你的情况下它不会,这很好。警告只是让你知道。
附带说明一下,如果参数类型是域 class、String
、8 种基本类型之一或 8 种类型包装器之一,则上述过程会有所不同。我上面描述的是系统对所有其他类型的行为方式。