我有一个Grails 2.0.1应用程序。我设置了以下UrlMapping:
"/"(controller:"home")
"500"(view:'/error/serverError')
"404"(view:'/error/notFound')
这是我的notFound.gsp页面:
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<meta name="layout" content="main"/>
<title>404 Not Found</title>
</head>
<body>
<h2>Page not found</h2>
<p>Back to <a href="${createLink(uri:'/')}">homepage</a></p>
</body>
</html>
在开发(在Tomcat下)时,404错误页面正确呈现主布局模板。 但是当我在Jetty 7.6.2下部署生产战争并浏览到一个不存在的url时,我得到404错误页面,但没有主布局模板。
因此,似乎Grails 2.0.1与Jetty不兼容,并且当遇到404错误时,应用程序无法呈现模板。
任何人都可以猜到我为什么会遇到这个问题?我在网上找不到任何东西。
由于
答案 0 :(得分:0)
你试过这个:http://www.javathinking.com/2007/12/404-with-grails/
您可以重定向到ErrorController,而不是直接转到gsp,而ErrorController又会重定向到不同的错误页面。
答案 1 :(得分:0)