使用 tomcat 文件夹之外的位置来存储和访问 Tomcat 8 中的图像文件 - GNU Linux OS [英] Using locations outside of tomcat folder to store and access Image files within Tomcat 8 - GNU Linux OS

查看:37
本文介绍了使用 tomcat 文件夹之外的位置来存储和访问 Tomcat 8 中的图像文件 - GNU Linux OS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行一个网页 + 一些在 GNU Linux 操作系统上运行的 Tomcat 中的 ws.搜索图像后页面将显示图像,实际图像位于 webapp/appname 文件夹内的文件夹中.最近系统内的可用空间不足,所以我要求系统管理员提供更多空间,作为回应,他们添加了一个新的 NetApp 卷并将其安装在 /data 文件夹中.这是在 Tomcat 文件夹之外,我无法访问它.环顾四周,我发现了这个网站:

I am running a webpage + some ws in Tomcat that is running on a GNU Linux OS. The page will display images after a search on the images, the actual images are located within a folder within the webapp/appname folder. Recently the free space within the system has gone short so I asked the sys admin for more space and in response they added a new NetApp volume and mounted it in /data folder. This is outside of the Tomcat folder and I am having difficulty accessing it. Looking around I found this site:

提供静态内容(包括 Web页面)从 WAR 外部使用 Apache Tomcat

但是这样的解决方案是当您想通过 url 访问图像时,我显示的图像显示在滑块中并指向 tomcat 中的文件夹.我还读到我可以为所有文件创建一个符号链接,但这行得通吗?滑块、bootstrap carousel 能用吗?轮播填充是用 javascript 完成的.

but such solution is for when you want to access the image through url, the images I am showing are shown in a slider and point to the folder within tomcat. I have also read that I can create a symlink for all the files, but will this work? will the slider, bootstrap carousel, work? the carousel population is done with javascript.

有人知道如何解决这个问题吗?

Does anyone have any idea how to solve this issue?

干杯,

es

推荐答案

经过一番搜索和阅读,我找到了适用于 Tomcat 8 的解决方案.为了能够在 Tomcat 之外的文件夹中存储和访问图像(文件)文件夹,您需要执行以下操作:

After some searching and reading, I founded the solution that works in Tomcat 8. To be able to store and then access images (files) on folders outside of Tomcat folder you need to do the following:

1- 在 conf/server.xml 的 节点中添加以下行:

1- Add the following line in the <host> node within the conf/server.xml:

<Context docBase="path to the location outside of tomcat" path="path  within tomcat"/>

2- 在 conf/context.xml 中的 块中添加以下内容

2- In the conf/context.xml add the following within the <Context> block

<Resource allowLinking="true">

3- 在应用程序 META-INF/context.xml 中也添加上述内容,在我的例子中它看起来像这样

3- In the application META-INF/context.xml add the above as well, in my case it looks like this

<?xml version="1.0" encoding0"UTF-8"?>
<Context path"/myapp">
 <Resource allowLinking="true">
</Context>

4-为位于外部文件夹中的所有文件创建符号链接,您可以运行以下命令

4- for all the files that are located in the outer folder create a symlink, you can run the following command

ln -s /path to other location/* ./images/

图像是我的网络应用程序中的文件夹.在此之后,外部位置的每个文件都会在 images 文件夹中创建一个链接.此解决方案的唯一问题是,每次更新应用程序或添加新图像时,您都需要再次创建符号链接.

the images is the folder within my web application. After this for each file in the outer location a link will be created within the images folder. The only problem with this solution is that each time you update the application or add a new image you will need to create the symlink(s) again.

希望能帮到你,加油

是.

这篇关于使用 tomcat 文件夹之外的位置来存储和访问 Tomcat 8 中的图像文件 - GNU Linux OS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆