我正在尝试从位于war文件之外的文件夹中呈现图像。我必须这样做才能防止在部署新的war文件时删除图像。
在我的开发机器上,我能够通过使用包含以下内容的_Event.groovy文件来完成此任务。
private string commaSeparateNumber(string value)
{
return String.Format("{0:#,##0}", int.Parse(value));
}
有了这个,我可以从我的Grails应用程序轻松访问图像。但是,当我将应用程序部署为JBoss实例中的war文件时,虚拟目录不起作用。
我已将此上下文文件添加到META-INF文件夹中,但它现在仍在使用。
import org.apache.catalina.loader.WebappLoader
eventConfigureTomcat = { tomcat ->
def newContextRoot = "img"
File newContextPath = new File( "c:/temp/img" )
if( newContextPath.exists() ) {
context = tomcat.addWebapp( newContextRoot, newContextPath.getAbsolutePath() )
context.reloadable = true
WebappLoader loader = new WebappLoader( tomcat.class.classLoader )
context.loader = loader
}
}
我在JBoss AS 7.1.1上运行Grails 2.3.8
非常感谢任何帮助或指导?