Silex Framework,找不到 POST 的路线

Silex Framework, no route found for POST

我的 silex 框架有点问题(我很确定,这是由 Silex 引起的)..

我有一个表单,想用 POST 提交它,但 Silex 抛出以下异常:

UrlMatcher.php 第 101 行中的 MethodNotAllowedException:

MethodNotAllowedHttpException RouterListener.php 第 149 行: 找不到 "POST /checkPW" 的路由:方法不允许(允许:GET)

这就是我的控制器的样子:

$app->get('/checkPW', function () use ($app) {
return $app['templating']->render(
    'checkPW_blog.php'
);
});

这就是表格的样子:

<form method="post" action="/checkPW">
                                            <div class="modal-body">
                                                <div class="form-group">
                                                    <input type="password" class="form-control" id="password"
                                                           name="password"
                                                           placeholder="Passwort">
                                                </div>
                                            </div>
                                            <div class="modal-footer">
                                                <button type="submit" class="btn btn-success" id="submitPW">
                                                    Passwort bestätigen
                                                </button>
                                            </div>
                                        </form>

(用Bootstrap实现)

奇怪的是,当我使用 GET 方法而不是 POST 发送表单时,一切正常...

有谁知道这里有什么问题..? 谢谢大家

看,你只为get定义了一条路线:

$app->get('/checkPW', function () use ($app) {
  return $app['templating']->render(
    'checkPW_blog.php'
  );
});

只需为post定义一个:

$app->post('/checkPW', function () use ($app) {
  // do post stuff...
});