我有这条路线:
_view_tag:
pattern: /topic/{tid}
defaults: {_controller: "MyCoreBundle:ViewTag:index" }
我想显示这样的网址:example.com/topic/Web+development。我用href="topic/{{ topicname|url_encode() }}". 它是有效的,但它当然不是正确的方法,所以我改为href="{{ path('_view_tag', {'tid': topicname|url_encode() } ) }}". 但它不是显示example.com/topic/Web+development,它显示example.com/topic/Web%2Bdevelopment。
我也试试这个:
{% set _tid = topicname|url_encode() %}
<a href="{{ path('_view_tag', {'tid': _tid } ) }}" ...
但仍然无法正常工作
example.com/topic/Web+development我的问题是,如何使用树枝路径功能使其显示?