[英]how to change route pattern in symfony2
In one of my symfony2 bundle I have the following file called registration.xml: 在我的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>
and here's my current routing.yml: 这是我当前的routing.yml:
fos_user_register:
resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
prefix: /register
The issue here is that when I try to print the route I am seeing: 这里的问题是,当我尝试打印路线时,我看到的是:
fos_user_registration_register ANY ANY ANY /register/
how do I remove the trailing slash at the end of /register/ ? 如何删除/ register /末尾的斜杠? So I wanted it to be just /register 所以我希望它只是/ register
I am not used to routing in XML but don't we have to use path=
instead pattern=
? 我不习惯使用XML进行路由,但是我们不必使用path=
代替pattern=
吗? And if that doesn't solve it you could try this: 如果那不能解决问题,您可以尝试以下操作:
YML 阳明海运
fos_user_register:
resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
prefix: /
XML 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>
Or perhaps path="/register"
instead of path="register"
或者也许是path="/register"
而不是path="register"
Anyhow you should really use the same format everywhere if you can. 无论如何,如果可以的话,您应该真正在所有地方都使用相同的格式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.