Symfony 3.2.4 通配符路由导致 100% cpu 利用率
Symfony 3.2.4 wildcard routing causes 100% cpu utilization
我有一个很奇怪的问题:
我有两条路线:
第一个带有通配符:
/**
* @Route("/test/{test}", name="test")
* @param type $route
*/
public function testAction(Request $request, $test) {
return $this->render('resource/showResource.html.twig', [
'test' => $test
]);
}
第二个没有通配符:
/**
* @Route("/test", name="test")
* @param type $route
*/
public function testAction(Request $request) {
return $this->render('resource/showResource.html.twig', [
'test' => 'something'
]);
}
问题是当我 运行 第一个 (http://localhost/app_dev.php/test/1) 我的 CPU 利用率几乎达到 100%(过程:httpd.exe => Apache HTTP 服务器。
第二个就没有这个问题
可能是什么原因造成的?
/**
* @Route("/test/{test}", name="test")
*/
public function testAction($test) {
return $this->render('resource/showResource.html.twig', [
'test' => $test
]);
}
试试下面的方法,也许对你有帮助:
/**
* @Route("/test/{test}", name="test", requirements={"test": "\d+"})
* @param type $route
*/
public function testAction(Request $request, $test) {
return $this->render('resource/showResource.html.twig', [
'test' => $test
]);
}
在http://symfony.com/doc/current/routing.html#adding-wildcard-requirements
上查看更多详细信息
问题已解决:
在文件 base.html.twig 中,我没有像这样工作的行:
<script src="../vendors/jquery/dist/jquery.min.js"></script>
现在我正在为他们使用资产,一切都很顺利。
感谢大家的付出! :)
我有一个很奇怪的问题:
我有两条路线: 第一个带有通配符:
/**
* @Route("/test/{test}", name="test")
* @param type $route
*/
public function testAction(Request $request, $test) {
return $this->render('resource/showResource.html.twig', [
'test' => $test
]);
}
第二个没有通配符:
/**
* @Route("/test", name="test")
* @param type $route
*/
public function testAction(Request $request) {
return $this->render('resource/showResource.html.twig', [
'test' => 'something'
]);
}
问题是当我 运行 第一个 (http://localhost/app_dev.php/test/1) 我的 CPU 利用率几乎达到 100%(过程:httpd.exe => Apache HTTP 服务器。
第二个就没有这个问题
可能是什么原因造成的?
/**
* @Route("/test/{test}", name="test")
*/
public function testAction($test) {
return $this->render('resource/showResource.html.twig', [
'test' => $test
]);
}
试试下面的方法,也许对你有帮助:
/**
* @Route("/test/{test}", name="test", requirements={"test": "\d+"})
* @param type $route
*/
public function testAction(Request $request, $test) {
return $this->render('resource/showResource.html.twig', [
'test' => $test
]);
}
在http://symfony.com/doc/current/routing.html#adding-wildcard-requirements
上查看更多详细信息问题已解决: 在文件 base.html.twig 中,我没有像这样工作的行:
<script src="../vendors/jquery/dist/jquery.min.js"></script>
现在我正在为他们使用资产,一切都很顺利。
感谢大家的付出! :)