[英]Unable to create a 404 page in Grails
My mappings look like 我的映射看起来像
static mappings = {
"/" (controller : "welcome", action : "index")
"/about" (controller : "welcome", action : "about")
"404" (controller : "welcome", action : "notFound")
}
This doesn't seem to catch 404 requests as I still get the default Tomcat 404 page. 这似乎没有捕获404请求,因为我仍然获得默认的Tomcat 404页面。 I have also tried the closure based method (below) with no success.
我也试过基于闭包的方法 (下面)没有成功。
"404" {
controller = "welcome"
action = "notFound"
}
Versions: 版本:
versions: {
app.version: "0.1"
app.servlet.version: "2.4"
app.grails.version: "1.3.5"
plugins.tomcat: "1.3.5"
plugins.hibernate: "1.3.5"
}
我已成功删除404行上的空格:
"404"(controller : "welcome", action : "notFound")
What version of Grails are you running? 你在运行什么版本的Grails?
Also, what does your controller action look like? 另外,你的控制器动作是什么样的? This person seems to have resolved the issue by using a redirect in their controller instead of a render:
此人似乎已通过在其控制器中使用重定向而不是渲染来解决此问题:
Problems with Grails 404 UrlMapping Grails 404 UrlMapping的问题
def notFound = {
redirect(uri:"/404.html")
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.