0

圣杯 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

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

4

1 回答 1

1

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

def show( Long id ) { }

相对

def show = {}

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

于 2012-12-24T01:33:14.923 回答