doubi1931 2018-09-18 14:38
浏览 143
已采纳

Symfony 3.4:路由匹配,但在网址中找不到路由

I've just created a new controller as i usually do but, this time I got a problem with routing.

In profiler route matches but I can't reach them and get No route found for "GET /prezzi/listino"

Controller

<?php

namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route;

class PricesController extends Controller {
    /**
     * @Route("/prezzi/listino", name="prezzi_listino")
     */
    public function pricesListAction()
    {
        $list = $this->getDoctrine()->getRepository('AppBundle:Prices')->findAll();

        return $this->render('prices/list.html.twig', [
            'items' => $list
        ]);
    }
}

Debug Router

$ php bin/console debug:router
 ----------------------------------- ---------- -------- ------ ------------------------------------------------------- 
  Name                                Method     Scheme   Host   Path                                                   
 ----------------------------------- ---------- -------- ------ ------------------------------------------------------- 
[..]
  prezzi_listino                      ANY        ANY      ANY    /prezzi/listino                                        
[..]
 ----------------------------------- ---------- -------- ------ ------------------------------------------------------- 

Router Match

$ php bin/console router:match --method GET /prezzi/listino



 [OK] Route "prezzi_listino" matches                                                                                    


+--------------+---------------------------------------------------------+
| Property     | Value                                                   |
+--------------+---------------------------------------------------------+
| Route Name   | prezzi_listino                                          |
| Path         | /prezzi/listino                                         |
| Path Regex   | #^/prezzi/listino$#sD                                   |
| Host         | ANY                                                     |
| Host Regex   |                                                         |
| Scheme       | ANY                                                     |
| Method       | ANY                                                     |
| Requirements | NO CUSTOM                                               |
| Class        | Symfony\Component\Routing\Route                         |
| Defaults     | _controller: AppBundle:Prices:pricesList                |
| Options      | compiler_class: Symfony\Component\Routing\RouteCompiler |
| Callable     | AppBundle\Controller\PricesController::pricesListAction |
+--------------+---------------------------------------------------------+

Any ideas of where is the error? I think is a distraction cause I haven't see this problem.

  • 写回答

1条回答 默认 最新

  • duanjia1870 2018-09-18 20:57
    关注

    Since I've tried to add the route in another controller that actually work, and doesn't seems to work, I've just come to the conclusion that I can't add any new route so it's meaning that is a cache error.

    Running php bin/console cache:clear --env=dev --no-warmup solve the problem.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效