dongyi0114 2016-06-10 13:04
浏览 16
已采纳

Zend框架路由问题

I have a module with the following in the module.config.php

<?php
return array(
        'controllers' => array(
                'invokables' => array(
                        'BlindQC\Controller\BlindQC' => 'BlindQC\Controller\BlindQCController',
                ),
        ),
        // The following section is new and should be added to your file
        'router' => array(
                'routes' => array(
                        'blinqc' => array(
                                'type' => 'Segment',
                                'options' => array(
                                        'route' => '/blindqc/jobs[/:user_id]',
                                        'defaults' => array(
                                                '__NAMESPACE__' => 'BlindQC\Controller',
                                                'controller' => 'BlindQC',
                                                'action' => 'index',
                                        ),
                                ),
                        ),
                ),
        ),
        'view_manager' => array(
                'template_path_stack' => array(
                        'blindqc' => __DIR__ . '/../view',
                ),
        ),
);

This allows me to go to www.example.com/blindqc/jobs or www.example.com/blindqc/jobs/123456

On this page I have a search box where the user can enter a user_id, which upon hitting Search should redirect them to the url followed by the entered user_id. So if they type 999999 it should take them to www.example.com/blindqc/jobs/999999. I seem to be having an issue using routes to get them there.

I've tried:

return $this->redirect()->toRoute("blindqc/jobs/", array("user_id" => $userId)); 

But I get an error:

Route with name "blindqc" not found

What am I doing incorrectly? As far as I can tell the route is defined correctly?

  • 写回答

1条回答 默认 最新

  • douzhang7728 2016-06-10 13:11
    关注

    The third line in the snippet below reads blinqc whereas it ought to be blindqc.

    'router' => array(
        'routes' => array(
            'blinqc' => array(
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 请求分析基于spring boot+vue的前后端分离的项目
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥20 为什么我写出来的绘图程序是这样的,有没有lao哥改一下
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥200 关于#c++#的问题,请各位专家解答!网站的邀请码
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么