简体   繁体   中英

The requested URL could not be matched by routing in zf2

I have this route:

 'editRelationship' => array(
                'type'    => 'Segment',
                'options' => array(
                    'route'    => '/editRelationship[/:state]',
                    'constraints' => array(
                        'state' => '[a-zA-Z][a-zA-Z0-9_-]*',
                      ),
                    'defaults' => array(
                         'controller' => 'User\Controller\Admin',
                        'action'        => 'editRelationship',
                    ),
                 ),
 ),

And this is my action controller:

 public function editRelationshipAction() {

    $state = $this->params()->fromRoute('state', null);

    $viewModel = new ViewModel();

    $viewModel->setVariable('state', $state);
    return $viewModel;
}

I try to access the url but whenever I'm accessing it I always get:

The requested URL could not be matched by routing.

May I know what is missing or wrong with my route?

Thanks in advance.

是的,确实我的问题出在我的整个路线上,我创建的路线应该在子路线上。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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