[英]how to change route pattern in symfony2
在我的symfony2软件包之一中,有以下文件称为registration.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
<route id="fos_user_registration_register" pattern="">
<default key="_controller">FOSUserBundle:Registration:register</default>
</route>
</routes>
这是我当前的routing.yml:
fos_user_register:
resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
prefix: /register
这里的问题是,当我尝试打印路线时,我看到的是:
fos_user_registration_register ANY ANY ANY /register/
如何删除/ register /末尾的斜杠? 所以我希望它只是/ register
我不习惯使用XML进行路由,但是我们不必使用path=
代替pattern=
吗? 如果那不能解决问题,您可以尝试以下操作:
阳明海运
fos_user_register:
resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
prefix: /
XML
<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
<route id="fos_user_registration_register" path="register">
<default key="_controller">FOSUserBundle:Registration:register</default>
</route>
</routes>
或者也许是path="/register"
而不是path="register"
无论如何,如果可以的话,您应该真正在所有地方都使用相同的格式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.