您好我正在使用Grails控制器从域类中删除数据,并且成功删除后我想重定向到一个非常具体的页面。有人能告诉我该怎么做吗? 我用Google搜索,发现此链接: http://grails.org/doc/latest/ref/Controllers/redirect.html 我只是不确定如何在控制器的定义中嵌入它:
def delete(DomainClass domainClass){ 响应domainClass视图:'confirmDelete' }
答案 0 :(得分:3)
如果要删除实例,请说
Book.groovy // domain object
Bookcontroller.groovy // controller
然后
// your delete logic
def delete() {
...
book.delete()// this performs the delete and upon successful deletion
redirect(controller: "book", action: "show")//you will be redirected to new page called show.gsp
...
}
希望这会对你有所帮助。
答案 1 :(得分:2)
如果重定向到同一个控制器:
def delete() {
// your delete code
redirect action: "someAction"
}
如果重定向到另一个控制器
def delete() {
// your delete code
redirect action: "someAction", controller: "someController"
}