NEO

蜀道难,难于上青天!

导航

Grails指南摘要-401-Controller中设置默认Action

Posted on 2013-06-04 23:04  页面载入出错  阅读(661)  评论(0编辑  收藏  举报

Controller中默认的Action是index,可以通过defaultAction指定默认的Action

// Here the 'list' action is the default as there is only one action defned
class SampleController {
    def list() {}
}

这个Controller中只有一个list Action,访问时需要定向到list才能访问到有效路径

// In this example 'index' is the default by convention
class SampleController {
    def list() {}
    def index() {}
}

这个Controller中有index和list两个action,系统会默认index为默认

// Here 'list' is explicitly set as the default
class SampleController {
    static defaultAction = 'list'
    def list() {}
    def index() {}
}

这个Controller中有两个action并指定list为默认,则系统会定向到list,并且在浏览器路径中不显示具体路径