grails:在开发中为嵌入式tomcat添加上下文 [英] grails: add context to embedded tomcat in development
本文介绍了grails:在开发中为嵌入式tomcat添加上下文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在制作过程中,我已经设置了一个外部文件夹来通过编辑server.xml来上传和显示
的图片:
In production I have setup an external folder to upload and display images from by editing 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在开发中做同样的事情:
I am trying to do the same thing in development by editing _Events.groovy :
eventConfigureTomcat = {tomcat ->
def ctx = tomcat.addContext("/imgs" , "/tmp/images")
}
我也试过
I also tried
eventConfigureTomcat = {tomcat ->
def ctx = tomcat.addContext("/appName/imgs" , "/tmp/images")
}
这不起作用,imgs目录无法通过以下方式访问:
http:/ / host / appName / imgs 任何想法如何正确地做到这一点?
this is not working, the imgs directory is not accessible via : http://host/appName/imgs any idea how I can do this correctly?
推荐答案
最后得到它感谢grails邮件列表:
finally got it thanks to the grails mailing list:
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
}
这篇关于grails:在开发中为嵌入式tomcat添加上下文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文