简体   繁体   English

Zend框架路由器404错误

[英]Zend framework router 404 error

Here is my zend framework module config: 这是我的zend框架模块配置:

 'routes' => [

            'home' => [
                'type' => Literal::class,
                'options' => [
                    'route'    => '/',
                    'defaults' => [
                        'controller' => Controller\IndexController::class,
                        'action'     => 'index',
                    ],
                ],
            ],

            'default' => array(
                'type' => 'segment',
                'options' => array(
                    'route'    => '/[:controller[/:action]]',
                    'defaults' => array(
                        '__NAMESPACE__' => 'Application\Controller',
                        'controller'    => 'Index',
                        'action'        => 'index',
                    ),
                    'constraints' => [
                        'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
                        'action'     => '[a-zA-Z][a-zA-Z0-9_-]*',
                    ]
                ),
            )
...  
 'controllers' => [
        'factories' => [
            Controller\IndexController::class => InvokableFactory::class,
        ],

and my IndexController.php looks like this: 和我的IndexController.php看起来像这样:

class IndexController extends AbstractActionController
{
    public function indexAction()
    {
        return new ViewModel();
    }

    public function testAction()
    {
        echo 1;
        return 1;
    }
}

I want get a right response when I access http://host/Index/test , but now I get a 404 error and a description like: 当我访问http://host/Index/test ,我想得到正确的响应,但是现在我收到404 error和类似的描述:

"The requested controller could not be mapped to an existing controller class ...". “请求的控制器无法映射到现有的控制器类...”。

What's the problem? 有什么问题?

尝试将'type' => 'segment'更改为'type' => 'Segment'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM