在生产环境中,我设置了一个外部文件夹以上传和显示
通过编辑server.xml获得的图像:
<Service name="Catalina">
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
URIEncoding="UTF-8"
redirectPort="443" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context docBase="/opt/winmail_storage/imgs" path="/imgs"/>
</Host>
</Engine>
</Service>
我正在尝试通过编辑_Events.groovy在开发中做同样的事情:
eventConfigureTomcat = {tomcat ->
def ctx = tomcat.addContext("/imgs" , "/tmp/images")
}
我也试过
eventConfigureTomcat = {tomcat ->
def ctx = tomcat.addContext("/appName/imgs" , "/tmp/images")
}
这不起作用,无法通过以下方式访问imgs目录:
http://host/appName/imgs知道我如何正确执行此操作吗?
最佳答案
终于通过grails邮件列表获得了它:
eventConfigureTomcat = {tomcat ->
def context = tomcat.addWebapp('/acrm/imgs' , '/tmp/images')
def loader = new WebappLoader(tomcat.class.classLoader)
loader.addRepository(new File('/home/mohadib/workspace/acrm/lib').toURI().toURL().toString())
loader.container = context
context.loader = loader
}