Html Grails response.sendError未呈现gsp标记
我试图在用户在url中输入无效id时显示404Html Grails response.sendError未呈现gsp标记,html,css,grails,Html,Css,Grails,我试图在用户在url中输入无效id时显示404 def show(Hero heroInstance) { if (heroInstance == null) { notFound() return response.sendError(404) } respond heroInstance } 404被映射到UrlMappings中找不到的自定义页面。但是,没有任何css被加载到页面中。我得到的只是一个页面,其中包含“未找到页面”文本
def show(Hero heroInstance) {
if (heroInstance == null) {
notFound()
return response.sendError(404)
}
respond heroInstance
}
404被映射到UrlMappings中找不到的自定义页面。但是,没有任何css被加载到页面中。我得到的只是一个页面,其中包含“未找到页面”文本
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<meta name="layout" content="main">
<title>PAGE NOT FOUND</title>
</head>
<body>
<h2>404</h2>
<p>
PAGE NOT FOUND
</p>
</body>
</html>
找不到页面
404
找不到页面
有没有办法使用sendError加载css?如果您有外部css,我认为您应该添加
<link rel="stylesheet" href="css/style.css" media="all" />
这是给你的
<head></head>
只有这样,您的css才会包含在html中
或
您可以使用
<style>
your css goes here
</style>
你的css在这里
您是否在单独的css文件中为此页面编写了css?是的。至少grails做到了。这只是我正在玩弄的一个入门应用程序。如果我给浏览器一个我的应用程序中不存在的页面,那么它会正确呈现404页面。e、 g.我的应用程序名为hello,我手动输入hello/notExistingPage,它将正确呈现404。嘿@akoEliaslopezlopezlopez你曾经解决过你的问题吗?我认为这可能也与这个问题有关:不,我们重新实现了很多代码,所以它对我们来说不是问题。我们基本上只是把后端变成了一个API,让AngularJS调用该API上的函数。所以grails不能处理我们的视图。