Grails running in Jetty renders 404 error page without layout template

半腔热情 提交于 2019-12-10 17:17:28

问题


I've a Grails 2.0.1 application. I set up the following UrlMapping:

"/"(controller:"home")
"500"(view:'/error/serverError')
"404"(view:'/error/notFound')

This is my notFound.gsp page:

<%@ 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>

While developing (under Tomcat) the 404 error page renders correctly main layout template. But when I deploy the war in production under Jetty 7.6.2 and I browse to a non-existing url I get the 404 error page but without the main layout template.

So it seems that Grails 2.0.1 doesn't play well with Jetty and the application can't render the template when a 404 error is hit.

Anyone can guess why I'm getting this issue ? I couldn't find anything in the net.

Thanks


回答1:


Have you tried this: http://www.javathinking.com/2007/12/404-with-grails/

Instead of going directly to the gsp, you can redirect to an ErrorController which in turn redirects to different error-pages.




回答2:


I manually wrapped the error page with

It's not elegant, but works.

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



来源:https://stackoverflow.com/questions/9657816/grails-running-in-jetty-renders-404-error-page-without-layout-template

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!