[英]Changing grails.serverURL has no effect on createLinkTo( […], absolute:'true')?
I'm trying to display a Java applet in a page on a Grails server. 我正在尝试在Grails服务器上的页面中显示Java applet。 I'm using Sun's handy Javascript snippet for displaying applets:
我正在使用Sun方便的Javascript代码片段显示小程序:
<script src="http://java.com/js/deployJava.js"></script>
<script>
deployJava.runApplet({codeBase:"${createLinkTo(dir:'applet', absolute:'true')}",
archive:"${createLinkTo(dir:'com/steve/applet', file='applet.jar', absolute:'true')}",
code:"com.steve.Applet.class",
width:"500", height:"500"}, null, "1.5");
</script>
In Config.groovy, I set up the different serverURLs: 在Config.groovy中,我设置了不同的serverURLs:
environments {
production {
grails.serverURL = "http://10.0.xx.xxx/"
}
development {
grails.serverURL = "http://10.0.yy.yyy:8080/"
}
}
However, the links created by createLinkTo() all have " http://localhost:8080 " instead of the URL I specified. 但是,由createLinkTo()创建的链接都具有“ http:// localhost:8080 ”,而不是我指定的URL。 (ie they look like " http://localhost:8080/my-app/applet ".) Is this a bug?
(即它们看起来像“ http:// localhost:8080 / my-app / applet ”。)这是一个错误吗? Is there a workaround?
有解决方法吗?
I found a workaround. 我找到了解决方法。 Instead of using createLinkTo, I just defined a new variable in Config.groovy:
我没有使用createLinkTo,而是在Config.groovy中定义了一个新变量:
environments {
development {
grails.appURL = "http://10.0.xx.xxx:8080/my-app"
}
production {
grails.appURL = "http://10.0.yy.yyy"
}
}
In my code, I do this: import org.codehaus.groovy.grails.commons.ConfigurationHolder as CH 在我的代码中,我这样做:将org.codehaus.groovy.grails.commons.ConfigurationHolder导入为CH
//...
def appURL = CH.config.grails.appURL
//...
This at least lets me get a predictable path. 这至少让我得到了可预测的路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.