2012-12-23 68 views
0

的Grails 1.3.5Grails的URL映射映射到错误的URL

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

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

为 “/顺序/显示/ 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 

我完全莫名其妙就这一个。无论哪种方式,它解决相同的问题。想法任何人?

回答

1

显然,在1.3.5中,当声明一个视图函数时,你不得不使用命名闭包而不是函数语法。

def show(Long id) { } 

def show = {} 

后者是正确的。如果有人可以说明为什么...