将查询字符串映射到Kohana 3.2中的控制器方法参数


Map query string to controller method parameter in Kohana 3.2

我想设置我的路由,使url如word/startswith?prefix=ab映射到以下代码

class Controller_Word extends Controller_Mytemplate {
    public function action_startswith($fragment){
     /// Here $fragment should get "ab" value.
    }
}

还有谁能告诉我如何在Kohana 3.2控制器中获得get数据?对于上面的场景,我可以通过

class Controller_Word extends Controller_Mytemplate {
    public function action_startswith($fragment=null){
        if($fragment==null){
            /// set $fragment to $_GET['prefix'] but in Kohana way.
        }
    }
}

为什么不直接使用$this->request->query('prefix')呢?

http://kohanaframework.org/3.2/guide/api/Request查询