Grails无法在搜索结果页面中显示状态名称

Grails无法在搜索结果页面中显示状态名称,grails,Grails,我已经使用可搜索插件在Grails应用程序中设置了一个搜索页面。我的搜索工作正常,但我遇到了一个小问题。在我的搜索结果(显示名称和状态)中,状态未显示 我有两个领域: class Person { String firstName String lastName State state } class State { String name String code String toString() return this.na

我已经使用可搜索插件在Grails应用程序中设置了一个搜索页面。我的搜索工作正常,但我遇到了一个小问题。在我的搜索结果(显示名称和状态)中,状态未显示

我有两个领域:

class Person {
    String firstName
    String lastName
    State state
}

class State {
    String name
    String code

    String toString()
        return this.name
    }
}
在我的search.gsp视图中,我有以下内容:

<g:each var="result" in="${searchResult.results}">

            <div class="searchResult">
                <div class="searchPerson">
                    <g:link controller="person" action="show" id="${result.id}">
                        ${result.lastName}, ${result.firstName}
                    </g:link>
                </div>
                <div class="searchAddress">
                    ${result.state}
                </div>
            </div>

</g:each>

${result.lastName},${result.firstName}
${result.state}
为什么我的州名没有出现?我尝试了以下方法:

<g:each var="result" in="${searchResult.results}">

            <div class="searchResult">
                <div class="searchPerson">
                    <g:link controller="person" action="show" id="${result.id}">
                        ${result.lastName}, ${result.firstName}
                    </g:link>
                </div>
                <div class="searchAddress">
                    ${result.state}
                </div>
            </div>

</g:each>
  • ${result.state.name}
  • ${result.state.code}
  • ${result.state.toString()}
我确信这个问题很小,但作为Grails的新来者,我似乎无法解决它。我将感谢任何帮助

Found(Grails中的即时抓取和可搜索插件),似乎是问题的原因,希望您的问题得到解决