tiles2 - 自定义404错误页面

时间:2012-02-07 02:00:53

标签: spring-mvc http-status-code-404 tiles2

我正在尝试与此主题中的人做同样的事情: How do I have common error page templates with tiles in a Spring/MVC 3.0 app?

然而,在该问题的接受解决方案之后似乎没有为我的404错误提供相同的结果。这个完全相同的设置可以解决500个错误!我有以下代码:

tiles.xml:

<definition name="error/404" extends="baseLayout">
    <put-attribute name="body" value="/WEB-INF/jsp/error/404.jsp" />
</definition>

/WEB-INF/jsp/error/404.jsp:

Error 404: This page doesn't exist, use the navigation on the left to find what you need

/WEB-INF/jsp/error/fullErrorPage/404.jsp:

<!-- this page is used by the web.xml to display an error VIEW, not just the error -->
<%@page isELIgnored="false" %>
<%@page contentType="text/html"%>
<%@taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>

<!-- insert the view -->
<tiles:insertDefinition name="error/404" /> 

的web.xml:

<error-page>
    <error-code>404</error-code>
    <location>/WEB-INF/jsp/error/fullErrorPage/404.jsp</location>
</error-page>

我认为问题在于,当我导航到我知道的URL不存在以触发404错误时,'error / 404'视图不可用。所有链接都可以正常工作,因为如果我将'fullErrorPage / 404.jsp'更改为一般错误页面并删除'tiles:insertDefinition',页面将正确呈现。但是,每当我尝试使用'tiles:insertDefinition'时,我只会得到一个通用的404错误页面。

tomcat日志文件似乎也表明存在某种无限循环,因为我假设每次尝试使用'tiles:insertDefinition'渲染'fullErrorPage / 404.jsp'时它会生成404错误,然后再次尝试渲染'fullErrorPage / 404.jsp'。

0 个答案:

没有答案
相关问题