配置Tomcat的虚拟路径 引用本地图片

需要修改你使用的Tomcat的service.xml文件:

如下:

 <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">

        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t "%r" %s %b" prefix="localhost_access_log" suffix=".txt"/>

      <Context docBase="F:\image" path="/ccyw/image" reloadable="true"/>
	  <Context docBase="02_CCYW" path="/ccyw" reloadable="true" source="org.eclipse.jst.jee.server:02_CCYW"/>
	  </Host>

然后上面的就通过localhost:端口名+ 上面的path值 +图片名  访问 Ip地址为 上面name的服务器 docBase 目录下的文件了

我的配置是通过localhost:8080/ccyw/image/..访问本地F:\image目录下的文件


eclipse 下配置


猜你喜欢

转载自blog.csdn.net/qq_36497454/article/details/80495578