tomcat 配置图片服务器

本文介绍如何使用Tomcat配置图片服务器,提供了四种定义上下文的方法,并详细解释了第三种方法的具体步骤。通过创建并配置XML文件,可以轻松实现图片资源的访问。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

参考文档

http://tomcat.apache.org/tomcat-8.0-doc/config/context.html

The Context element represents a web application, which is run within a particular virtual host.

 

Defining a context

方法一:Place <Context> elements directly in the server.xml file,but it is NOT recommended to.

方法二:In an individual file at /META-INF/context.xml inside the application files. 

方法三:In individual files (with a ".xml" extension) in the $CATALINA_BASE/conf/[enginename]/[hostname]/ directory.

方法四:Inside a Host element in the main conf/server.xml.

 

方法三 配置图片服务器:

第一步:创建pic.xml文件

$CATALINA_BASE\conf\Catalina\localhost\pic.xml

第二步:编辑内容

<Context docBase="D:\\pic"></Context>

第三步:启动tomcat

第四步:将123.png图片放置在D:\\pic文件夹下

第五步:访问 http://localhost:8080/pic/123.png

 

属性说明

详情见参考文档。

补充:以方法三配置的图片服务器中,不需要设置path ,因为默认取文件名(除去.xml后缀)

The context path and version will be derived from the base name of the file (the file name less the .xml extension). 

 

转载于:https://www.cnblogs.com/zno2/p/5728751.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值