2

有没有办法通过 Intelli-J 启动应用程序,使其成为localhost:8080/应用程序的根?我遇到的问题是在本地工作的 AJAX url 在生产中不起作用,并且createLink(action:"ajaxUpdate")似乎创建了对在/app/ajaxUpdate本地工作但在生产中不起作用的引用。

有没有办法修复createLink在这两个地方工作?我想也许我可以使用 UrlMappings 来使所有的 ajax 调用变得漂亮并且只引用/ajaxUpdate,但这不起作用,因为 grails 应用程序是如何部署在 Intelli-J 中的。

我该如何解决?

4

1 回答 1

6

关于您的问题,您可以在grails-app/conf/Config.groovy中指定服务器 URL,如下所示:

environments {
    production {

        grails.serverURL = "http://localhost/"  // Specify the "root" of your link
        ....
    }

    development {
        grails.serverURL = "http://localhost:8080/${appName}"
        ...
    }
    ...
}

那么 createLink 方法应该没问题。据我所知,它与 Grails 配置有关,与 IntelliJ 无关。

编辑:似乎我错过了一些信息:要使 createLink 从“http://localhost/”开始,有必要在 Config.groovy 中添加另一行:

grails.app.context = "/"
于 2011-02-14T07:09:50.073 回答