我有一些顯示.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