2014-02-14 32 views
0

嘗試使用basic app示例Yii2,並且在路由方面存在一些問題。我有一個簡單的登錄表單,並在提交時調用正確的控制器操作,但$ _POST數據爲空。在Yii中調試程序,一切看起來都在日誌中確定,除了這行:yii2'請求的路由'在調試器中爲空

3 18:57:49.307 trace yii\web\Application::handleRequest Route requested: '' 

路線沒有被正確處理,但我不知道下一個嘗試的東西。 「基本應用程序」附帶登錄表單視圖,路由工作正常。這裏是我的形式:

<form class="navbar-form navbar-right" role="form" id="du-lts-rm-login-form" method="post"> 
       <div class="form-group"> 
       <input type="text" class="form-control" placeholder="DU ID number"> 
       </div><br> 
       <div class="form-group"> 
       <input type="text" class="form-control" placeholder="DU Password"> 
       </div> 
       <button type="submit" class="btn btn-default">Submit</button> 
     </form>  

以下是完整的跟蹤:

1 18:57:49.306 trace yii\base\Module::getModule Loading module: debug 
    2 18:57:49.307 trace yii\web\UrlManager::parseRequest Pretty URL not 
    enabled. Using default URL parsing logic. 
    3 18:57:49.307 trace yii\web\Application::handleRequest Route requested:  
    '' 
    4 18:57:49.307 trace yii\base\Controller::runAction Route to run: site/index 
    5 18:57:49.307 trace yii\base\InlineAction::runWithParams Running action: 
    app\controllers\SiteController::actionIndex() 
    6 18:57:49.307 trace yii\base\View::renderFile Rendering view file: 
    /home/t/Documents/records/views/site/index.php 
    /home/t/Documents/records/controllers/SiteController.php (59) 
    7 18:57:49.307 trace yii\base\View::renderFile Rendering view file: 
    /home/t/Documents/records/views/layouts/main.php 
    /home/t/Documents/records/controllers/SiteController.php (59) 

請求正文是空的,但路由看起來正確:

 Route 'site/index' 
     Action 'app\\controllers\\SiteController::actionIndex()' 
在響應頭

你也可以看到下面的引用者是不正確的。應該看起來像'https://localhost/records/web/index.php?r=site/index'.

Request Headers 
    Name Value 
    host 'localhost' 
    connection 'keep-alive' 
    content-length '0' 
    cache-control 'max-age=0' 
    accept 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' 
    origin 'https://localhost' 
    user-agent 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko)   
      Chrome/32.0.1700.107 Safari/537.36' 
    content-type 'application/x-www-form-urlencoded' 
    referer 'https://localhost/records/web/' 
    accept-encoding 'gzip,deflate,sdch' 
    accept-language 'en-US,en;q=0.8' 
    cookie ... 

任何幫助表示讚賞。

回答

0

我沒有任何表單輸入的名稱或ID。現在它可以工作。