tomcat 配置图片服务器
参考文档
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).