在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 ×1