如何访问tomcat所在服务器的其他盘符的资源。

<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
        <Context path="/FoodStore-Images" docBase="D:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\FoodStore\FoodStore-Images" ></Context>

        <!-- 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 &quot;%r&quot; %s %b" prefix="localhost_access_log." suffix=".txt"/>

</Host>

再tomcat的conf\server.xml的host标签下加上 <Context path="/FoodStore-Images" docBase="D:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\FoodStore\FoodStore-Images" ></Context>代码,即可用http://ip地址:端口号/FoodStore-Images/文件名.后缀名  来访问"D:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\FoodStore\FoodStore-Images"路径下的文件资源。

posted @ 2017-03-31 15:28  我不会游泳  阅读(493)  评论(0)    收藏  举报