在收到此消息时,我无法确定出现错误的位置:
在渲染模板期间抛出了异常 ("无法生成指定路由的网址"核心"作为此类路由 不存在。")在app / Resources / views / globalheader.html.twig中 第3行。
globalheader.html.twig是:
{# app/Resources/views/globalheader.html.twig #}
<div id="globalheader">
<h1><a href="{{ path('core') }}">MyListProject</a></h1>
<div class="usermenu">
{% block globalheader_usermenu %}{% endblock %}
</div>
</div>
routing.yml:
user:
resource: "@UserBundle/Resources/config/routing.yml"
prefix: /user
rpg_db:
resource: "@RPGBundle/Resources/config/routing.yml"
prefix: /rpg
core:
resource: "@CoreBundle/Controller/"
type: annotation
prefix: /
CoreBundle DefaultController:
namespace MyProject\System\CoreBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
class DefaultController extends Controller
{
/**
* @Route("/")
* @Template()
*/
public function indexAction($name = null)
{
return array();
}
}
我做错了什么?或者其他地方可能是我的问题?
答案 0 :(得分:1)
将name
添加到路线定义中:
class DefaultController extends Controller
{
/**
* @Route("/", name="core")
* @Template()
*/
public function indexAction($name = null)
{
return array();
}
}