嗨,我有这项服务:
def insertAction(int Id, String Name){
def sql = new Sql(dataSource)
sql.execute("INSERT INTO mn (id, name) VALUES ($Id,$Name)")
}
这个 Controller :
def save() {
println params
[contact: contactListService.insertAction(params.id,params.Name)]
redirect action: "create"
当我创建一个新条目时,我得到这个错误
没有方法签名:contactlist.ContactListService.insertAction() 适用于参数类型:(null, java.lang.String) 值:[null, das] 可能的解决方案:insertAction(int, java.lang.String) , 列表 Action ()
最佳答案
嗯,就像错误提示的那样。
您将第一个参数定义为 int
,但您将其指定为 null
。
null
可以用于任何对象,但不能用于像 int
这样的基本类型。
将您的方法参数更改为类似 Integer
的对象(或 def
不指定显式类型)并检查您的方法中的 null
,或在将其值赋给方法之前检查您的params
。
关于postgresql - 方法 [] 的签名不适用于参数类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36572620/