私はこのスレッドの男と同じことをしようとしています: Spring/MVC 3.0 アプリでタイルを使用した一般的なエラー ページ テンプレートを使用するにはどうすればよいですか?
ただし、その質問の受け入れられた解決策に従っても、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>
問題は、404 エラーをトリガーするために存在しないことがわかっている URL に移動すると、「エラー/404」ビューが利用できないことだと思います。「fullErrorPage/404.jsp」を一般的なエラー ページに変更し、「tiles:insertDefinition」を削除すると、ページが適切にレンダリングされるため、すべてのリンクが正常に機能します。ただし、「tiles:insertDefinition」を使用しようとすると、代わりに一般的な 404 エラー ページが表示されます。
tomcat のログ ファイルも、何らかの無限ループが発生していることを示しているようです。これは、「fullErrorPage/404.jsp」を「tiles:insertDefinition」でレンダリングしようとするたびに 404 エラーが生成され、その後に発生すると想定しているためです。 「fullErrorPage/404.jsp」をもう一度レンダリングしようとします。