2012-02-10 126 views
3

我有一個Grails 2.0 webapp,當我嘗試去一個url,例如 http://localhost:8080/ $ {myapp}/controller/action它總是重定向到http://localhost:8080/controller/action,沒有我的webapp名字。 這是我UrlMappings.groovyGrails url重定向問題

class UrlMappings { 
static mappings = { 
    "/$controller/$action?/$id?"{ 
     constraints { 
     // apply constraints here 
     } 
    } 

    "/"(controller:"/admin") 
    "500"(view:'/error') 
} 

}

這是我application.properties

#Grails Metadata file 
#Thu Feb 09 12:22:14 CET 2012 
app.grails.version=2.0.0 
app.name=appname 
app.servlet.version=2.4 
app.version=0.1 
plugins.hibernate=2.0.0 
plugins.tomcat=2.0.0 

任何建議,爲什麼會重定向到錯誤的URL?

感謝您的時間

+1

你設置'grails.app.context = 「/ APPNAME」'在你的'Config.groovy'中? – 2012-02-10 15:17:08

+0

感謝您的回覆,我會在星期一嘗試,我不在辦公室 – 2012-02-10 16:08:23

回答

4

問題解決了。在Config.groovy中我的服務器地址是錯的

grails.serverURL="http://localhost:8080"

我不得不使用

grails.serverURL="http://localhost:8080/appname"

感謝

+0

這個答案幫助了我另一種方式。我們以前沒有在Config.groovy中使用這個設置。最近有人檢查了這一行,我的本地Grails應用程序正在重定向到這個特定的8080 URL,即使我在8080以外的其他端口上運行它。 – tusar 2016-01-27 13:01:28