将 Web 应用程序外部的目录映射到 TOMCAT 中的 URL [英] Mapping a directory outside the web-app to URL in TOMCAT

查看:18
本文介绍了将 Web 应用程序外部的目录映射到 TOMCAT 中的 URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要映射一个包含位于 tomcat webapps 文件夹之外的图像的目录,以便应用程序可以提供这些图像.

I need to map an directory containing images which resides outside tomcat webapps folder, so that application can serve those images.

我正在制作一个在 tomcat 6 下运行的 J2EE Web 应用程序.用户可以在应用程序中上传/删除图像.目前,我将这些图像存储到应用程序的 WebContent 文件夹下的目录中,但我想将其带出 tomcat(例如 C:/test/images).

I am making a J2EE Web application running under tomcat 6. User can upload/delete images in the application. Currenly I store these images to a directory under application's WebContent folder, but I want to take it outside the tomcat (e.g. C:/test/images).

我需要知道如何配置 tomcat 以便如果我访问 URL http://.com/images/abc.jpg ,它会提供来自目录 C:/test/images 的图像

I need to know how to I configure tomcat so that if I access URL http://.com/images/abc.jpg , it serves the image from directory C:/test/images

谢谢,

推荐答案

在 server.xml 中添加一个 标签,在 标签内:

Add a <Context> tag in server.xml, inside the <Host> tag:

<Context path="/images" docBase="C:/test/images/" />

文档可通过 http://localhost:8080/images

这篇关于将 Web 应用程序外部的目录映射到 TOMCAT 中的 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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