在Jetty中运行的Grails呈现404错误页面,而无需布局模板 [英] Grails running in Jetty renders 404 error page without layout template

查看:107
本文介绍了在Jetty中运行的Grails呈现404错误页面,而无需布局模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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 =layoutcontent =main/>
< title> 404未找到< / title>
< / head>

< body>未找到
< h2>页面< / h2>
< p>回到< a href =$ {createLink(uri:'/')}> homepage< / a>< / p>
< / body>
< / html>

开发(在Tomcat下)404错误页面正确呈现主布局模板。
但是当我在Jetty 7.6.2的生产环境中部署战争时,我浏览到一个不存在的URL时,我得到了404错误页面,但没有主要布局模板。



因此,似乎Grails 2.0.1在Jetty中不能很好地发挥作用,并且在遇到404错误时应用程序无法呈现模板。



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



谢谢

解决方案

我用
手动包装错误页面



这不是优雅的,但可以工作。 a href =http://grails.org/doc/latest/ref/Tags/applyLayout.html =nofollow> http://grails.org/doc/latest/ref/Tags/applyLayout.html


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

解决方案

I manually wrapped the error page with

It's not elegant, but works.

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

这篇关于在Jetty中运行的Grails呈现404错误页面,而无需布局模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆