0
我是grails的新手,我試圖訪問索引頁。刪除Grails的默認主頁後,我收到以下錯誤 404應用1/WEB-INF /的grails-app /視圖/ index.jsp的無法在grails中訪問index.gsp
description The requested resource is not available.
我檢查urlMapping中和視圖設置爲指數
"/"(view:"/index")
"500"(view:'/error')
我的控制器類
package App1grailsapp
class TeamController {
def index() { }
def teams()
{
[teams:Team.list()]
}
}
而且我有兩個GSP頁面,
指數
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Sample title</title>
</head>
<body>
<h2><g:message code="welcome"/></h2>
<ul>
<li><g:link action="teams">Display all teams</g:link></li>
</ul>
</body>
</html>
和團隊
<html>
<head>
<meta name="layout" content="main">
<title>Teams</title>
</head>
<body>
<h2>Teams:</h2>
<table>
<tr>
<thead>
<th>Name</th>
</thead>
</tr>
<g:each var="team" in="${teams}">
<tr>
<td>${team.name}</td>
</tr>
</g:each>
</table>
</body>
</html>
我不明白爲什麼index.gsp中的網頁沒有被顯示?
您的GSP頁面位於您的項目中? –
在視圖和佈局 – Sky
根據你發佈的內容你應該有在grails-app/views/team/index.gsp下的index.gsp這是當你訪問團隊的URI時將會呈現的視圖。但是,我不認爲這是你的意圖。如果你想顯示teams.gsp,你需要渲染(view:'teams',model:[teams:Teams.list()])並且在grails-app/views/team/teams.gsp下有teams.gsp。默認的index.gsp應該在grails-app/views/index.gsp下 –