如何获取当前 url 参数以传入 href link

How to fetch current url parameter to pass in a href link

当前 Url:http://localhost/invite_project/web/app_dev.php/api/getall/5

重定向Url

<a href="{{ absolute_url(asset(''))}}app_dev.php/create/{ 'id': app.request.get('_route_params') }" class="btn btn-primary">Create>

我无法使用 app.request.get('_route_params')

在 twig 文件中获取 Id=5

{{app.request.attributes.get('_route_params').id}} 我在 url 中使用了它并且有效!