我有一些显示.gsp文件的问题,我不太确定原因。我有以下代码:Grails webapp不显示gsp页面
class UrlMappings{
static mappings = {
"/"(controller: 'index', action: 'index')
}
}
class IndexController{
def index(){
render(view: "index")
}
}
然后在的grails-app /视图/索引我有index.gsp中:
<!DOCTYPE html>
<html>
<head>
<title>Hello World</title>
</head>
<body>
Hello World
</body>
</html>
当我打http://localhost:8080/我得到一个500个状态码错误。但是,如果我将IndexController更改为
render "Hello World"
它将显示“Hello World”,因此该应用似乎正在启动。
有谁知道发生了什么事?堆栈跟踪的一部分:
17:09:40.677 [http-nio-8080-exec-1] ERROR o.a.c.c.C.[.[.[.[grailsDispatcherServlet] - Servlet.service() for servlet [grailsDispatcherServlet] in context with path [] threw exception [Could not resolve view with name '/index/index' in servlet with name 'grailsDispatcherServlet'] with root cause
javax.servlet.ServletException: Could not resolve view with name '/index/index' in servlet with name 'grailsDispatcherServlet'
似乎很奇怪。只要确保你已经运行了经典的'grails clean'和Grails运行时重启。 – Yuri
避免使用框架中具有特定含义的名称。如果您将索引更改为其他内容,是否会得到相同的错误? – Armaiti
也不会'http:// host/index/index'看起来有点不对?无论如何,“/ index”(controller:'aha',action:“nice”)然后将'/ index'重定向到其他一些控制器动作,你可以为'/ index/index'编写它,但是认为它看起来像一个小奇怪的人开始质疑开发者的技能:) – Vahid