在Jetty中运行的Grails渲染404错误页面而没有布局模板

时间:2012-03-11 18:44:42

标签: grails jetty

我有一个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错误时,应用程序无法呈现模板。

任何人都可以猜到我为什么会遇到这个问题?我在网上找不到任何东西。

由于

2 个答案:

答案 0 :(得分:0)

你试过这个:http://www.javathinking.com/2007/12/404-with-grails/

您可以重定向到ErrorController,而不是直接转到gsp,而ErrorController又会重定向到不同的错误页面。

答案 1 :(得分:0)

我用手动包装了错误页面

它不优雅,但有效。

http://grails.org/doc/latest/ref/Tags/applyLayout.html