久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

CakePHP 3:存在的路由缺少路由錯誤

CakePHP 3: Missing route error for route that exists(CakePHP 3:存在的路由缺少路由錯誤)
本文介紹了CakePHP 3:存在的路由缺少路由錯誤的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

CakePHP 3.0

CakePHP 3.0

對于存在的路線,我收到了缺少路線"的錯誤消息.

I'm getting a "Missing Route" error for a route that exists.

這是我的路線:

#my admin routes...
Router::prefix('admin', function($routes) {
    $routes->connect('/', ['controller'=>'Screens', 'action'=>'index']);
    $routes->connect('/screens', ['controller'=>'Screens', 'action'=>'index']);
    $routes->connect('/screens/index', ['controller'=>'Screens', 'action'=>'index']);
    //$routes->fallbacks('InflectedRoute');
});

Router::scope('/', function ($routes) {

    $routes->connect('/login', ['controller' => 'Pages', 'action' => 'display', 'login']);    
    $routes->connect('/pages/*', ['controller' => 'Pages', 'action' => 'display']);

    $routes->fallbacks('InflectedRoute');
});

Plugin::routes();

基本上我只是將頂部(用于管理路由)添加到開箱即用的默認路由中.

Basically I just added the top section (for admin routing) to the default routes that come out of the box.

當我訪問 /admin/screens/index 時,我看到以下錯誤:

When I visit /admin/screens/index I see the following error:

注意錯誤信息說:

錯誤:匹配array ('action' => 'add', 'prefix' =>'admin', 'plugin' => NULL, 'controller' => 'Screens', '_ext' => NULL,)"無法找到.

Error: A route matching "array ( 'action' => 'add', 'prefix' => 'admin', 'plugin' => NULL, 'controller' => 'Screens', '_ext' => NULL, )" could not be found.

...這很奇怪,因為我沒有嘗試訪問 add 操作.下面打印的參數看起來是正確的.

...which is strange because I am not trying to access the add action. The params printed below look correct.

這是怎么回事?

推薦答案

仔細看一下stacktrace,錯誤dosn't occurring in the dispatching process,你似乎認為,它是在你的視圖模板中觸發的,您可能正在嘗試創建指向 add 操作的鏈接,并且反向路由找不到匹配的路由,因此出現錯誤.

Take a closer look at the stacktrace, the error dosn't occour in the dispatching process, which you seem to think, it is being triggered in your view template, where you are probably trying to create a link to the add action, and reverse-routing cannot find a matching route, hence the error.

解決方案應該是顯而易見的,連接必要的路由,像

The solution should be obvious, connect the necessary routes, being it explicit ones like

$routes->connect('/screens/add', ['controller' => 'Screens', 'action' => 'add']);

包羅萬象

$routes->connect('/screens/:action', ['controller' => 'Screens']);

或者只是捕獲一切的后備

or simply the fallback ones that catch everything

$routes->fallbacks('InflectedRoute');

這篇關于CakePHP 3:存在的路由缺少路由錯誤的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Cannot use #39;Object as class name as it is reserved Cake 2.2.x(不能使用 Object 作為類名,因為它是保留的 Cake 2.2.x)
Session is lost after an OAuth redirect(OAuth 重定向后會話丟失)
Pagination Sort in Cakephp 3.x(Cakephp 3.x 中的分頁排序)
CakePHP Shared core for multiple apps(CakePHP 多個應用程序的共享核心)
Login [ Auth-gt;identify() ] always false on CakePHP 3(在 CakePHP 3 上登錄 [ Auth-identify() ] 始終為 false)
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 87 bytes)(致命錯誤:允許的內存大小為 134217728 字節已用盡(嘗試分配 87 字節))
主站蜘蛛池模板: 国产精品69av | av中文字幕在线观看 | 国产一区二区三区四区五区加勒比 | 日韩在线一区二区三区 | 亚洲精品国产第一综合99久久 | 日日骚av | 欧美激情一区二区三区 | 欧美黄 片免费观看 | 男女羞羞视频在线免费观看 | 高清av在线 | 日韩在线视频免费观看 | 欧美a v在线 | 国产精品色 | 亚洲成人一区二区在线 | 欧美一区二区三区视频 | 日韩不卡一区二区 | 亚洲精品久久久久久久久久久久久 | 欧美精品国产一区二区 | 天堂精品 | 北条麻妃一区二区三区在线视频 | 国产精品久久久久久久久婷婷 | 国产精品不卡 | 午夜激情国产 | 91精品久久久 | 日本精品一区二区三区在线观看视频 | 九九热热九九 | 久久久123 | 999精品视频| 午夜电影日韩 | 婷婷中文在线 | 激情伊人网 | 日韩精品免费在线观看 | av网站在线播放 | www国产亚洲精品久久网站 | 国产午夜精品久久 | 欧美亚洲国产一区二区三区 | 久一久| 女女爱爱视频 | 成人在线视频一区 | av电影一区二区 | 日本天天操|