Grails的urlMappings动作和控制器行为不使用控制器逻辑

问题描述:

我有一个Grails应用,在那里urlMappings.groovy文件的内容是:Grails的urlMappings动作和控制器行为不使用控制器逻辑

"/" { 
    controller="home" 
    view="home" 
} 

我家的控制器看起来像

class HomeController { 
    List products = [ 
     ['price': 100, 'desc':'a'], 
     ['price': 200, 'desc':'b'] 
    ] 

    def home() { 
     [products: products] 
    } 

当我浏览到localhost:8080/myProject/home/home ,我有权访问"${products}",但是当我导航到localhost:8080/myProject时,"${products}"语句为空。

为什么会这样,我怎样才能使localhost:8080/myProject的行为与localhost:8080/myProject/home/home一样?

你应该做

"/"(controller: 'home', action: 'home') 
+0

Woops!如果认为名称不是行动,那是什么造成的。 – 2014-10-18 11:56:19