【发布时间】:2014-10-17 12:37:13
【问题描述】:
我是 grails 的新手,我正在尝试用它编写一个简单的博客应用程序。我有一些资源,我正在尝试实现创建资源逻辑。 这是我所做的;
标签的 URL 映射;
"/tags"(resources: 'tags')
标签控制器;
class TagsController {
def index() {
[tags: Tag.list()]
}
def create() { }
def save() {
def tag = new Tag(params.tag)
if(tag.save()) {
flash.message = "Tag Created Successfully"
redirect(action: "index")
}
else {
flash.error = "Something went wrong, please check the form again!"
render(view: "create")
}
}
def show() {
render "this is the show action"
}
}
使用此配置 redirect(action: "index") 重定向到标签/索引路径。但此路径不适用于索引操作,而是用于显示操作。
我做错了什么?
我试过这样的 URL 映射;
"/tags"(resources: 'tag')
在这种情况下,tags/ 和 tags/index 路径会触发索引操作,但 tags/6(6 是数据库中现有标签的 id)不会触发显示操作。
【问题讨论】:
标签: grails redirect grails-controller