0

我想在 url 中发送变量,但我不知道如何像这样发送它们:url/page=1&element=a&...&...&...&.. 因为当我使用普通的 symfony url 时,我没有在正确的位置获得变量。

我把它变成了 symfony 的默认 URL:

pattern:  /url/{a}/{b}/{c}/{d}/{e}

但是如果我只发送“e”例如我的代码将它作为“a”

4

1 回答 1

0

Acces the url with query parameters if you want: /url?page=1&foo=bar. Your routing looks then very simple

my_route:
    pattern: /url
    default: # bla

in your controller action (you have to take care on validating the values):

use Symfony\Component\HttpFoundation\Request;

public function updateAction(Request $request)
{
    $page = $request->query->get('page');
}

If you want a cleaner way, you should take a look at the ParamFetcher of the FOSRestBundle

于 2013-08-20T17:08:57.857 回答