[英]Symfony2 special chars in route path
Symfony2 by default displays entity details by ID 默认情况下,Symfony2按ID显示实体详细信息
/**
* Finds and displays a State entity.
* @Route("state/{id}", name="state_show")
* @Template()
*/
I'd like to display name of the state, but most of states contains special chars (Polish special chars). 我想显示州的名称,但大多数州都包含特殊字符(波兰特殊字符)。
Links work if I use {name} but it is safe to use special chars in link? 如果我使用{name}链接工作,但在链接中使用特殊字符是安全的吗?
Since you are not going to encode the URL, characters other than the following are unsafe. 由于您不打算对URL进行编码,因此以下字符不安全。
alphanumeric, 字母数字,
Reserved ";", "/", "?", ":", "@", "=", "&"
, 保留
";", "/", "?", ":", "@", "=", "&"
,
Special characters: $-_.+!*'(),
. 特殊字符:
$-_.+!*'(),
See this related answer . 看到这个相关的答案 。
在我看来,最好的方法(也适用于SEO)是将波兰字母改为标准字母(例如ł=> l,±=> a)并使用 - 作为单词分隔符
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.