1

我正在尝试与该线程中的人做同样的事情: 如何在 Spring/MVC 3.0 应用程序中使用带有磁贴的常见错误页面模板?

但是,遵循该问题的公认解决方案似乎并没有为我的 404 错误提供相同的结果。然而,这个完全相同的设置确实适用于 500 个错误!我有以下代码:

瓷砖.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" /> 

网页.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”。

4

0 回答 0