Launching a grails-app through Intelli-J with root set to localhost:8080/ instead of localhost:8080/app, or modifying createLink?

穿精又带淫゛_ 提交于 2019-12-21 21:53:48

问题


Is there a way to launch an application through Intelli-J so that it makes localhost:8080/ the root of the application? The problem I'm having is that AJAX urls that work locally don't work in production, and createLink(action:"ajaxUpdate") seems to create references to /app/ajaxUpdate, which works locally but not in production.

Is there a way to fix createLink to work in both locations? I thought perhaps I could just use UrlMappings to make all the ajax calls pretty and just refer to /ajaxUpdate, but that doesn't work because of how the grails application is deployed within Intelli-J.

How do I fix this?


回答1:


About your problem, in grails-app/conf/Config.groovy you can specify the server URL, like this:

environments {
    production {

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

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

Then the createLink method should be fine. As I know, it's about Grails config, not relate to IntelliJ.

EDIT: It seems that I missed some information: to make the createLink start at "http://localhost/", it's necessary to add another line into Config.groovy:

grails.app.context = "/"


来源:https://stackoverflow.com/questions/4989528/launching-a-grails-app-through-intelli-j-with-root-set-to-localhost8080-instea

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!