【发布时间】:2013-05-20 15:50:55
【问题描述】:
我必须升级以前由其他人使用 Symphony 1.4 开发的应用程序。
在我的 action.class.php 中有两个不同的函数:
public function executeCreateTask(sfWebRequest $request) {...}
public function executeCreateEvent(sfWebRequest $request) {...}
在我的 routing.yml 我有 2 条路线:
evaluation_task_create:
url: /evaluation/:id/task/create
class: sfDoctrineRoute
options: { model: Evaluation, type: object }
param: { module: evaluation, action: createTask, sf_format: html }
requirements: { sf_method: post }
和
evaluation_event_create:
url: /evaluation/:evaluation_id/event/create
class: sfDoctrineRoute
options: { model: CustomEvent, type: object }
param: { module: evaluation, action: createEvent, sf_format: html }
requirements: { sf_method: post }
网址 http://www.mysite/evaluation/21/task/create 完美运行(创建新任务)
网址 http://www.mysite/evaluation/21/event/create 返回 404 错误。
知道我为什么会遇到这个路由问题吗?
【问题讨论】:
-
您是在执行 GET 还是 POST 请求?请注意,您的第二条路由包含
requirements: { sf_method: post }。如果这不是问题,您的debug设置是否设置为 true?您收到的确切错误消息是什么? -
请求由带有 POST 方法的表单触发。我没有收到任何错误,它只是跳转到 Symfony 的 404 错误页面。
-
这个错误页面说什么?您是否收到带有
Empty module and/or action after parsing the URL "/evaluation/21/event/create" (/).之类消息的 sfError404Exception`? -
我真的不知道 sfDoctrineRoute 的作用,因为我使用的是 Propel,但数据库中是否存在主键为 21 的 CustomEvent?
-
“糟糕!找不到页面,服务器返回 404 响应。”日志文件没有错误。 21 是 evaluation_id 的值。也许我错了,但我认为这是一个路由错误,但我不明白为什么......
标签: symfony1 symfony-1.4 yaml