如何创建"别名"在Apache Tomcat上? [英] How do you create "Aliases" in Apache Tomcat?
问题描述
我工作的一个Web应用程序,允许用户上传附件。这些附件存储在不同的驱动器的Web应用程序上。如何创建一个别名(相当于Apache的HTTP服务器的别名)这个驱动器,这样用户就可以下载这些附件?
目前我创建一个背景文件,并在CATALINA_HOME为之倾倒/ conf目录/卡塔利娜/本地主机,但它获取随机删除每隔一段时间。上下文文件名为attachments.xml和内容如下。我也看到了有关虚拟主机,但如果我理解正确的话,那么虚拟主机是不是我期待的。我使用的Apache Tomcat版本6.0.18。
的 attachments.xml:的
<?XML版本=1.0编码=UTF-8&GT?;
<上下文的docBase =E:\\上传\\附件
重载=真
crossContext =真正的>
< /语境GT;
我花了很多时间研究这个发现解决了上下文文件的随机删除的解决方案。我发现在Apache的网站上此摘录下的主机配置部分:
您可以嵌套一个或多个上下文
该主机元素中的元素,
每次重新presenting不同的网络
应用程序与此相关
虚拟主机。
块引用>该虚拟主机存储在位于* CATALINA_HOME \\ conf下的 server.xml中的文件,*。 Tomcat的所配置的本地主机的作为默认主机。所以,如果我们从第一篇文章中添加的 attachments.xml 的内容,我们得到如下:
<主机名=本地主机的appBase =的webapps
unpackWARs =真正的自动部署=真
xmlValidation =假xmlNamespaceAware =假> <上下文路径=/附件
的docBase =E:\\上传\\附件
重载=真
crossContext =真/>
< /主机>这是接近人能得到界定别名类似Apache的HTTP服务器,我想。
I am working on a web application that allows users to upload attachments. These attachments are stored on a different drive than that of the web application. How can I create an alias (equivalent to Apache HTTP server's aliases) to this drive so that users can download these attachments?
Currently I am creating a context file and dumping it in CATALINA_HOME/conf/Catalina/localhost, but it gets randomly deleted every so often. The context file is named attachments.xml and the contents are shown below. I have also read about virtual hosts, but if I understand correctly, then a virtual host is not what I am looking for. I am using version 6.0.18 of Apache Tomcat.
attachments.xml:
<?xml version="1.0" encoding="UTF-8"?> <Context docBase = "e:\uploads\attachments" reloadable = "true" crossContext = "true"> </Context>
解决方案I spent a lot more time researching this and found a solution that solves the random deletion of the context files. I found this excerpt on Apache's website under the host configuration section:
You can nest one or more Context elements inside this Host element, each representing a different web application associated with this virtual host.
The virtual hosts are stored in the server.xml file located at *CATALINA_HOME\conf*. Tomcat comes configured with localhost as the default host. So, if we add the contents of attachments.xml from the first post, we get the following:
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> <Context path="/attachments" docBase="e:\uploads\attachments" reloadable="true" crossContext="true" /> </Host>
This is as close as one can get to defining aliases similar to Apache's HTTP server, I think.
这篇关于如何创建&QUOT;别名&QUOT;在Apache Tomcat上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!