Grails,相同控制器和动作的不同 url
Grails, different url for same controller and action
我在 grails 中有这个 urlMappings
"/"(controller: 'home', action: 'index')
"/$id"(controller: 'home', action: 'index')
有没有更好的方法来写这个,没有重复的代码?
如果我只使用一个,另一个 urlMapping 将不起作用。
提前致谢
如果您想合并两个 URL 映射,您可以将 id
参数设为可选,如下所示:
"/$id?"(controller: 'home', action: 'index')
我在 grails 中有这个 urlMappings
"/"(controller: 'home', action: 'index')
"/$id"(controller: 'home', action: 'index')
有没有更好的方法来写这个,没有重复的代码? 如果我只使用一个,另一个 urlMapping 将不起作用。
提前致谢
如果您想合并两个 URL 映射,您可以将 id
参数设为可选,如下所示:
"/$id?"(controller: 'home', action: 'index')