小编Rem*_*let的帖子

Symfony2:在Controller参数中自动映射查询字符串

在Symfony2中,路由参数可以自动映射到控制器参数,例如:http://a.com/test/foo将返回"foo"

    /**
     * @Route("/test/{name}")
     */
    public function action(Request $request, $name) {
        return new Response(print_r($name, true));
    }
Run Code Online (Sandbox Code Playgroud)

请参阅http://symfony.com/doc/current/book/routing.html#route-parameters-and-controller-arguments

但我想使用查询字符串,例如:http://a.com/test ?name = foo

怎么做 ?对我来说,只有3个解决方案:

还有其他解决方案吗?

symfony

3
推荐指数
1
解决办法
2773
查看次数

标签 统计

symfony ×1