1

尝试Yii2使用该basic app示例,但在路由方面遇到了一些问题。我有一个简单的登录表单,提交时调用了正确的控制器操作,但 $_POST 数据为空。在 Yii 调试器中,日志中的一切看起来都正常,除了这一行:

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  ...

任何帮助表示赞赏。

4

1 回答 1

1

我没有任何用于表单输入的名称或 ID。现在它起作用了。

于 2014-02-17T16:59:38.450 回答