通过将根设置为localhost:8080 /而不是localhost:8080 / app或修改createLink的Intelli-J启动grails-app? [英] Launching a grails-app through Intelli-J with root set to localhost:8080/ instead of localhost:8080/app, or modifying createLink?

查看:128
本文介绍了通过将根设置为localhost:8080 /而不是localhost:8080 / app或修改createLink的Intelli-J启动grails-app?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法通过Intelli-J启动应用程序,以便使应用程序的根目录为 localhost:8080 / ?我遇到的问题是,在本地工作的AJAX网址在生产中不起作用,并且 createLink(action:ajaxUpdate)似乎创建对<$ c>的引用

有没有办法解决 / app / ajaxUpdate ,它在本地工作, createLink 在两个位置工作?我想也许我可以使用UrlMappings来完成所有的ajax调用,并引用 / ajaxUpdate ,但这不起作用,因为grails应用程序是如何部署的Intelli-J。



我该如何解决这个问题?

解决方案

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

  environments {
production {

grails.serverURL =http:// localhost ///指定链接的根
... 。
}

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

然后createLink方法应该没问题。据我所知,这是关于Grails配置,与IntelliJ无关。

编辑:似乎我错过了一些信息:使createLink在http://开始

  grails.app.context =/$ blocalhost /,则需要在Config.groovy中添加另一行。 $ b  


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?

解决方案

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 = "/"

这篇关于通过将根设置为localhost:8080 /而不是localhost:8080 / app或修改createLink的Intelli-J启动grails-app?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆