在制作中,我设置了一个上传和显示的外部文件夹 来自编辑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我知道如何正确地做到这一点?
答案 0 :(得分:4)
终于得到了感谢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
}