0

当我运行服务器并尝试 URL 时,我收到错误 404。

src/AppBundle/Resources/config/routing.yml

app_category:
    resource: "@AppBundle/Resources/config/routing/category.yml"
    prefix:   /category

src/AppBundle/Resources/config/routing/category.yml

category:
    path:     /
    defaults: { _controller: "AppBundle:Category:index" }
category_new:
    path:     /new
    defaults: { _controller: "AppBundle:Category:new" }

类别控制器

class CategoryController extends Controller
{

    /**
     * Lists all Category entities.
     *
     */
    public function indexAction()
    {
        $em = $this->getDoctrine()->getManager();

        $entities = $em->getRepository('AppBundle:Category')->findAll();

        return $this->render('AppBundle:Category:index.html.twig', array(
            'entities' => $entities,
        ));
    }

    public function newAction()
    {
        $entity = new Category();
        $form   = $this->createCreateForm($entity);

        return $this->render('AppBundle:Category:new.html.twig', array(
            'entity' => $entity,
            'form'   => $form->createView(),
        ));
    }

}

在此处输入图像描述 在此处输入图像描述

我究竟做错了什么?

4

0 回答 0