質問

リダイレクトでパラメータを通過させることは可能ですか?私はたくさんのオプションを試しましたが、何も機能しないようです。私の最新のアプローチは次のとおりです。

return $this->redirect(array('Users::helloworld', 'args' => array('id' => 'myId')));
.

それから私はルートを作成しました:

Router::connect('/Users/helloworld?id={:id}', array('controller' => 'Users', 'action' => 'helloworld'));
.

しかし私が得るのは一般的なものです。

役に立ちましたか?

解決

argsはルートの一部であり、非常に一般的なルートを使用してURLに変換されます(作成したものではなく、必要ではない)

query string を取得するには、?キーを使用するだけです。

return $this->redirect(array(
    'Users::helloworld',
    '?' => array('id' => $myId)
));
// will use the route:
//    /{:controller}/{:action}/{:args}
// and generate
//    /users/helloworld?id=$myId
.

そのテスト: https://github.com/unionofrad/lithium/blob/master/tests/case/net/http/routetest.php#L374-405

他のヒント

引数を渡すための別のルートを定義する代わりに、次の手順を実行できます。 $ arg1 $ arg2 helloworld コントローラの helloworld アクション:

return $this->redirect(array(
'Users::helloworld',
'args' => array(
        $arg1,
        $arg2
    )
));
.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top