我正在使用symfony 1.0,并为一些URL设置了路由,如下所示。
static_pages:
url: docs/:page.htm
param: { module: docs, action: index }
现在,我已经为不同类型的 URL 设置了路由。
URL is http://news4u.com/search/description/id/3/css/a/act/a
我已将路由设置为如下
description:
url: /search/description/id/:id/css/:manu/act/:mgh
param: { module: search, action: description}
这是获取"css"和"act"值的正确格式吗? 当URL缺少css参数时,我的意思是如果URL如下所示:
http://news4u.com/search/description/id/3/css//act/a
- getRequestParameter('css') 的值显示为 'act' 和的值 - getRequestParameter('act') 为空
因此,我尝试应用路由,如果我错了,请纠正我。我没有得到想要的使用上面的路由配置。
您不一定需要在 routing.yml 文件中指定"id"、"css"和"act"作为参数,除非您在 URL 中使用它们的存在将用户引导至搜索模块和说明操作。
在 routeting.yml 中使用以下规则仍然有效:
default:
url: /:module/:action/*
然后你应该能够使用
url_for('search/description', array(
'id' => 4,
'css' => 'something',
'act' => 'blah'
);
生成如下链接:/search/description/id/4/css/something/act/blah