Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Symfony2路由错误未找到“的路由”;获取/查询";_Php_Symfony_Routes_Http Status Code 404 - Fatal编程技术网

Php Symfony2路由错误未找到“的路由”;获取/查询";

Php Symfony2路由错误未找到“的路由”;获取/查询";,php,symfony,routes,http-status-code-404,Php,Symfony,Routes,Http Status Code 404,我在Symfony2 v2.3中创建新路线时遇到问题。我收到错误信息 No route found for "GET /query" 404 Not Found - NotFoundHttpException 1 linked Exception: ResourceNotFoundException » 我一直在寻找解决方案,但都没有成功。。。我甚至在一台服务器上试用appDevUrlGenerator.php和appDevUrlMatcher.php时崩溃了 下面是我的DefaultCont

我在Symfony2 v2.3中创建新路线时遇到问题。我收到错误信息

No route found for "GET /query"
404 Not Found - NotFoundHttpException
1 linked Exception: ResourceNotFoundException »
我一直在寻找解决方案,但都没有成功。。。我甚至在一台服务器上试用appDevUrlGenerator.php和appDevUrlMatcher.php时崩溃了

下面是我的DefaultController中的部分代码:

public function queryAction(Request $request)
{
    $repository=$this->getDoctrine()->getRepository('TestFirstBundle:UserTicket');


    $lists = $repository->findBystatus('Open');


    if (!$lists) {
        throw $this->createNotFoundException(
            'No forms found '
        );
    }

    return $this->render('TestFirstBundle:Default:query.html.twig', array(
        'lists' => $lists,

    ));
my routing.yml内部捆绑包:

test_First_homepage:
path:     /dipl
defaults: { _controller: TestFirstBundle:Default:index }


test_First_submit:
path:     /subm
defaults: { _controller: TestFirstBundle:Default:submit }

test_First_query:
path:     /query
defaults: { _controller: TestFirstBundle:Default:query }
和app/config/routing.yml(我在app/config/routing_dev.yml中放了同样的东西)

我只想补充一点,/dipl和/subm路由工作得很好,它们连接到索引和submitAction,我把表单放在那里(在提交表单后重定向)。另外,如果我注释掉我真正的indexAction并将queryAction重命名为indexAction,它在/dipl url上工作得非常好,并且做的事情与queryAction应该做的完全一样。所以我猜queryAction和/查询url之间的连接存在问题。但是当我跑的时候

   php app/console router:match /query 
我得到了正确的答案:

[router] Route "test_First_query"
Name         test_First_query
Path         /query
Host         ANY
Scheme       ANY
Method       ANY
Class        Symfony\Component\Routing\Route
Defaults     _controller:           Test\FirstBundle\Controller\DefaultController::queryAction
Requirements NO CUSTOM
Options      compiler_class: Symfony\Component\Routing\RouteCompiler
Path-Regex   #^/query$#s

我想这可能是一条保留路线或其他什么,但我也在使用symfony 2.3,这个快速测试效果很好:

/**
 * @Route("/query", name="query")
 */
public function queryAction()
{
    return new Response('query');
}

我会得到回复的。所以不是这样。可能是您在Symfony2之外的/query下配置了某种别名或资源(可能在您的HTTP服务器中?),以某种方式干扰了此路由?

我尝试了该操作/路由/url的随机名称,无论我如何命名,都是一样的。另外,我正在运行localhost,这是我的第一个项目
/**
 * @Route("/query", name="query")
 */
public function queryAction()
{
    return new Response('query');
}