1

次のようにルーティングしたい:http: //myapp.com/mycontroller /...?x= ..。

mycontrollerの後のすべてが不明です。パスがわからず、パラメータもわかりません。パスとパラメータをルーティングした後、1つの変数として表示されます。

// route in routes.php
Router::connect('/mycontroller/*', 'Mycontroller::index');

// the index function of Mycontroller class
public function index($pathWithParameters) {
    print_r($pathWithParameters); // something like: 'hello/world?name=mewel&id=123
}

これは可能ですか?

4

1 に答える 1

6
Router::connect('/mycontroller/{:args}', 'Mycontroller::index');

次に、コントローラーから、を確認$this->request->paramsし、$this->request->query

注意:func_get_args()コントローラーでも使用できます。例としてデフォルトのPagesControllerを見てください

于 2012-02-24T01:55:17.263 に答える