【问题标题】:Grails URL Mapping maps to wrong urlGrails URL Mapping 映射到错误的 url
【发布时间】:2012-12-23 23:44:58
【问题描述】:

Grails 1.3.5

在我的应用程序中映射到新控制器时:

"/order/$action/$id?" {
  controller = "customerOrder"
}

对“/order/show/13”的请求解析为“/()/()?/(*)?”如日志中所示:

17:53:02 DEBUG  UrlMappingsFilter - Matched URI [/order/show/13] to URL mapping [/(*)/(*)?/(*)?], forwarding to [/grails/home/page.dispatch] with response [class org.codehaus.groovy.grails.web.sitemesh.GrailsContentBufferingResponse]

如果我添加这个映射:

"/order/show/13"{
  controller = "customerOrder"
  action = "show"
  id = 13
}

它仍然解析为“/()/()?/(*)?”。我编辑了映射:

"/customerOrder/show/13"{
  controller = "customerOrder"
  action = "show"
  id = 13
}

和日志报告:

18:50:08 DEBUG  DefaultUrlMappingsHolder - Matched URI [/customerOrder/show/13] with pattern [/customerOrder/show/13], adding to posibilities

后来它还报告:

18:50:08 DEBUG  DefaultUrlMappingsHolder - Matched URI [/customerOrder/show/13] with pattern [/(*)/(*)?/(*)?], adding to posibilities

我对这个完全感到困惑。无论哪种方式,它都解决了相同的问题。任何人的想法?

【问题讨论】:

    标签: grails url-mapping


    【解决方案1】:

    显然,在 1.3.5 中,您必须在声明视图函数时使用命名闭包而不是函数语法。

    def show( Long id ) { }
    

    def show = {}
    

    后者是正确的。如果有人能解释为什么......

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多