2012-02-10 128 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