Groovy奇怪的错误

时间:2011-05-25 16:13:15

标签: grails groovy

 class Area {

        String name
        String description

        static constraints = {
        }

_

 class SearchIndexing {

        String search
        Area area

        static constraints = {
        }
    }  

_

 <%

            def area = cm.Area.get(1)

            def si = new cm.SearchIndexing()

            def concat   

            concat = area.name // i wanna join here more things with much bigger class

            si.search = concat
            si.area = area
            si.save()

            out << searchIndexing.list()

            %>

ERROR:

No signature of method: cm.SearchIndexing.save() is applicable for argument types: () values: [] Possible solutions: wait(), any(), wait(long), any(groovy.lang.Closure), isCase(java.lang.Object), use([Ljava.lang.Object;) 

2 个答案:

答案 0 :(得分:0)

当然你没有初始的+号,即:

def temp = + obj2.prop1 + " " + ...

为什么不尝试更加时髦的方式:

def temp = "$obj2.prop1 $obj2.prop2 ..."

或者:

def temp = [ obj2.prop1, obj2.prop2 ].join( ' ' )

答案 1 :(得分:0)

从您创建SearchIndexing

实例的方式开始
def si = new cm.SearchIndexing()

它看起来像是一个内部阶级。我不认为域类可以是内部类,这可以解释为什么它没有save()方法。