Symfony2 - 从不显示自定义错误页面 [英] Symfony2 - Custom error pages are never shown
问题描述
我正在尝试自定义 error.html.twig、error403.html.twig、error404.html.twig 和 error500.html.twig,到目前为止我已经尝试得到导致的 error403.html.twig 错误通过 AccessDeniedExceptionw 这是一个 403 禁止,但它显示自定义错误页面.我在 app/Resources/TwigBundle/views/Exception 中创建了模板,就像它说的 here 但到目前为止,没有运气.
所有模板都扩展了网站基础模板
403:
{% extends '::base.html.twig' %}{% 块体 %}<div id="标题"><a href="{{path ('login')}}" class="fl"><img src="{{ asset('images/access_error.png') }}" alt="TiCad"/></a><div class="fr"><h1>HA 发生错误:</h1></div><div align="center">没有posee permisos suficientes para acceder a esta seccion, si desea ingresar con otra coenta haga clic <a href="{{path ('login')}}">AQUI</</div>{% 结束块 %}
404:
{% 扩展 '::base.html.twig' %}{% 块体 %}<div id="标题"><a href="{{path ('login')}}" class="fl"><img src="{{ asset('images/error404.png') }}" alt="TiCad"/></a><div class="fr"><h1>HA 发生错误:</h1></div><div align="center">没有矛盾.赞成,新意.</div>{% 结束块 %}
500:
{% 扩展 '::base.html.twig' %}{% 块体 %}<h1><img src="{{ asset('images/internal_server.png') }}" alt="Monse"/>糟糕!Ha ocurrido un error<h2>内部服务器错误</h2><div>算法没有功能.赞成,Háznos saber que estabas haciendo cuando ocurrio este 错误,envia un email a <a href="mailto:ticad@icad.com.ve">ticad@icad.com.ve</a>Lo arreglaremos lo mas pronto posible.iCad Diseno Inteligente, C.A.se disculpa por los inconvenientes causados.
{% 结束块 %}
我做错了什么?
自定义模板不会显示在您的开发中.环境.您可以使用生产环境对其进行测试,只需确保清除缓存即可.
I'm trying to customize the error.html.twig, error403.html.twig, error404.html.twig and error500.html.twig, so far i've tried to get the error403.html.twig error caused by an a AccessDeniedExceptionw which is a 403 forbidden, but it displays the custom error page. I created the templates inside app/Resources/TwigBundle/views/Exception like it says here but so far, no luck.
All the templates extend the website base template
403:
{% extends '::base.html.twig' %}
{% block body %}
<div id="header">
<a href="{{path ('login')}}" class="fl"><img src="{{ asset('images/access_error.png') }}" alt="TiCad" /></a>
<div class="fr"><h1>HA OCURRIDO UN ERROR:</h1></div>
<div align="center">No posee permisos suficientes para acceder a esta seccion, si desea ingresar con otra cuenta haga clic <a href="{{path ('login')}}">AQUI</a></div>
{% endblock %}
404:
{% extends '::base.html.twig' %}
{% block body %}
<div id="header">
<a href="{{path ('login')}}" class="fl"><img src="{{ asset('images/error404.png') }}" alt="TiCad" /></a>
<div class="fr"><h1>HA OCURRIDO UN ERROR:</h1></div>
<div align="center">No encontrado. Por favor, intente de nuevo.</div>
{% endblock %}
500:
{% extends '::base.html.twig' %}
{% block body %}
<h1><img src="{{ asset('images/internal_server.png') }}" alt="Monse" />Oops! Ha ocurrido un error</h1>
<h2>Error interno en el servidor</h2>
<div>
Algo no funciona. Por favor, Háznos saber que estabas haciendo cuando ocurrio este error, envia un email a <a href="mailto:ticad@icad.com.ve">ticad@icad.com.ve</a>
Lo arreglaremos lo mas pronto posible. iCad Diseno Inteligente, C.A. se disculpa por los inconvenientes causados.
</div>
{% endblock %}
What am i doing wrong?
Custom templates won't show in your dev. environment. You can test them using production environment, just make sure to clear the cache.
这篇关于Symfony2 - 从不显示自定义错误页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!