Grails 控制器错误

发布于 2024-11-10 07:29:44 字数 1421 浏览 2 评论 0原文

def results = {

    def results = [:]
    def conferences = Conference.list() // lista das conferencias

    String [] conf_origin // array de strings da indexação da classe
    String [] conf_search  = params.conferenceName.split() // array de strings palavras da pesquisa
    boolean test // teste double for

          conferences.each{

                conf_origin = "hi i'm john".split() // indexação
                //conf_origin = "aveiroa".split()
                OUTER: for(int i = 0; i< conf_origin.length; i++){
                            for(int j = 0; j< conf_search.length; j++) {

                                    if(conf_origin[i] == conf_search[j]){
                                        test = true
                                        results.put(it.id, it)
                                        break OUTER;
                                    }
                                }
                            }

                        }

    return [results : results]
}

嘿我有这个问题。如果我返回:“[会议:会议]”我的 gsp 成功地完成了我想要的操作。尽管如此,当我返回“[结果:结果]”(推测是经过过滤的会议地图)时,会显示以下错误,我无法弄清楚原因:

Exception Message: No such property: yearCount for class: java.util.LinkedHashMap$Entry 

PS。基本上,我有

String [] conf_origin --->这是一个字符串数组

String[]conf_search --->这是搜索栏中引入的单词的字符串数组。

然后我比较两个数组,如果有一个匹配,我会中断 for 并将该会议对象添加到结果中。

def results = {

    def results = [:]
    def conferences = Conference.list() // lista das conferencias

    String [] conf_origin // array de strings da indexação da classe
    String [] conf_search  = params.conferenceName.split() // array de strings palavras da pesquisa
    boolean test // teste double for

          conferences.each{

                conf_origin = "hi i'm john".split() // indexação
                //conf_origin = "aveiroa".split()
                OUTER: for(int i = 0; i< conf_origin.length; i++){
                            for(int j = 0; j< conf_search.length; j++) {

                                    if(conf_origin[i] == conf_search[j]){
                                        test = true
                                        results.put(it.id, it)
                                        break OUTER;
                                    }
                                }
                            }

                        }

    return [results : results]
}

Hey i am having this problem. If i return: "[conferences: conferences]" my gsp sucessfully do what i want. Altought, when i return '[results: results]' which is suposelly a filtered map of conferences, the folowing error is displayed and i cant figure it out why:

Exception Message: No such property: yearCount for class: java.util.LinkedHashMap$Entry 

PS. Basically, i have

String [] conf_origin ---> which is a String array of words

String [] conf_search ---> which is a string array of introduced words in search bar.

Then i compare both arrays, and if there's one match, i break the for and add that conference object to results.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小嗲 2024-11-17 07:29:44

conferences 是一个 List(属于 Conference,但在 Groovy 中是无类型的),results 是一个 地图。您需要:

  • 将其设为 ConferenceList
  • 或返回 [conferences: results.values()]
  • 或调整 GSP 页面以进行迭代在地图上。

请注意,conferences 是您的 GSP 代码所依赖的变量名称。

conferences is a List (of Conference, but it's untyped in Groovy), and results is a Map. You need either to:

  • make it a List of Conference
  • or return [conferences: results.values()]
  • or adjust your GSP page to iterate over a Map.

Note that conferences is a variable name your GSP code relies onto.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文