槽形怪异错误

问题描述

|
 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()

            %>
错误
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;) 
    

解决方法

确保您没有首字母+,即:
def temp = + obj2.prop1 + \" \" + ...
为什么不尝试更普通的方式,例如:
def temp = \"$obj2.prop1 $obj2.prop2 ...\"
要么:
def temp = [ obj2.prop1,obj2.prop2 ].join( \' \' )
    ,从创建
SearchIndexing
实例的方式
def si = new cm.SearchIndexing()
它看起来像是一个内部类。我不认为域类可以是内部类,这可以解释为什么它没有
save()
方法。