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
我对这个感到非常困惑。无论哪种方式,它都解决了同样的问题。想法有人吗?
答案 0 :(得分:1)
显然,在1.3.5中,在声明视图函数时,必须使用命名闭包而不是函数语法。
def show( Long id ) { }
与
def show = {}
后者是正确的。如果有人可以解释为什么......