簡體   English   中英

Zend框架路由器404錯誤

[英]Zend framework router 404 error

這是我的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,
        ],

和我的IndexController.php看起來像這樣:

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

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

當我訪問http://host/Index/test ,我想得到正確的響應,但是現在我收到404 error和類似的描述:

“請求的控制器無法映射到現有的控制器類...”。

有什么問題?

嘗試將'type' => 'segment'更改為'type' => 'Segment'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM