1

我有映射:

"/$controller/$action?/$id?"{
            constraints {
                // apply constraints here
            }
        } // i used scaffolding and i think this is required by the generated stuff
'/'(controller:'home') //for the home page
'/$param1?/$param2?'(controller:'search') //for a search page 

需要在浏览器中显示的 url 是:
www.site.com/ - 主页

www.site.com/keyword1/keyword2 - 通过这些可选关键字进行搜索

这似乎可行,但我的问题是:我可以期望这是正确的,还是在某些情况下 grails 会把事情搞混?

4

1 回答 1

1

它不会。Grails 将根据一组给定的优先规则(从特定到一般)对您的 url 映射进行排序。

您的网址将始终相同并返回相同的页面。

但是,由于您的映射不明确,有时它可能会返回您不期望的页面。更好的设计是将搜索映射到:

/搜索/params1?/params2?

这种方式是明确的。

于 2011-02-09T10:03:08.093 回答