Symfony:未找到获取路线http://localhost/SymfonyCRUD/web/app_dev.php/


Symfony: No route found for get http://localhost/SymfonyCRUD/web/app_dev.php/hello

我开始学习Symfony,遇到了这个问题>>Symfony:找不到获取的路径http://localhost/SymfonyCRUD/web/app_dev.php/hello.我已经确保我在routing.yml文件中输入的参数是正确的,但错误仍然存在于我的浏览器中。路由.YML

custom_book_homepage:
    pattern:  /hello
    defaults: { _controller: CustomBookBundle:Default:index }

控制器文件

class DefaultController extends Controller
{
    public function indexAction()
    {
        return $this->render('CustomBookBundle:Default:index.html.twig');
    }
}

请问可能出了什么问题?

关于您的yaml:的2条评论

  1. 从Symfony文档中,模式参数必须是路径
  2. 您的yaml是无效的yaml,因此可能会出现解析错误

试试这个:

custom_book_homepage:
  path: /hello
  defaults: 
    _controller: "CustomBookBundle:Default:index"