0
我在啓動服務器並嘗試訪問http://127.0.0.1:8000時收到錯誤Unable to generate a URL for the named route "login" as such route does not exist.
。無法爲指定的路由「登錄」生成URL
到/登錄直接訪問,得到:No route found for "GET /login"
這是symfony3和無FOSBUNDLE! 基於symfony3 cookbook traditional log form。
security.yml:
securityController.php:
// src/AppBundle/Controller/SecurityContoller.php
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
class SecurityController extends Controller
{
/**
* @Route("/login", name="login")
*/
public function loginAction(Request $request)
{
$authenticationUtils = $this->get('security.authentication_utils');
// login error, if there is one
$error = $authenticationUtils->getLastAuthenticationError();
// last username entered
$lastUsername = $authenticationUtils->getLastUsername();
return $this->render(
'security/login.html.twig',
array(
'last_username' => $lastUsername,
'error' => $error,
)
);
}
}
請問你的routing.yml文件是什麼樣子? – Laoneo
它的默認值是否需要手動添加到routing.yml中,即使使用註釋? – Diamonte
是的,你需要添加一個路由文件。我發佈了一個答案,需要什麼。 – Laoneo