0
在grails中,假設您有一個名爲'MainProject'的項目,我的默認索引是http://localhost:8080/MainProject/
,與此確切URL關聯的頁面是views/index.gsp
。Grails - 如何定義起始索引頁面URL
我想項目的起始鏈接不是http://localhost:8080/MainProject/
而是類似http://localhost:8080/MainProject/users/login
。
我試圖從這個編輯URL映射:
class UrlMappings {
static mappings = {
"/$controller/$action?/$id?(.$format)?"{
constraints {
// apply constraints here
}
}
"/"(view: '/index')
"500"(view:'/error')
}
}
這樣:
class UrlMappings {
static mappings = {
"/$controller/$action?/$id?(.$format)?"{
constraints {
// apply constraints here
}
}
"/"(view: '/users/login')
"500"(view:'/error')
}
}
上述更改後,通過啓動該項目,該網址仍然是http://localhost:8080/MainProject/
,但頁面所示不是views/index.gsp
而是views/users/login.gsp
。 gsp被正確渲染,但url仍然不是我需要的。
如何解決這個問題?
我相信你會跟這樣做: ' 「/」(重定向: '/用戶/登錄')' – adamcooney