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

查看:155
本文介绍了将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.

我正在运行J2EE Web应用程序tomcat 6.用户可以在应用程序中上传/删除图像。 Currenly我将这些图像存储在应用程序的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

谢谢,

推荐答案

在< Host>标记内的server.xml中添加< Context>标记:

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

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

可以在 http:// localhost:8080 / images <访问文档/ code>

Docs will be accessible at http://localhost:8080/images

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

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