tomcat 添加虚拟路径

来源:互联网 发布:时间校正软件 编辑:程序博客网 时间:2024/06/09 15:53

在tomcat的conf的server.xml中, 添加如下代码即可

<Context docBase="E:/ueditor_upload_file" path="/ueditor_upload_file" reloadable="true"/>


标红色的是实际路径,黑色的path的值是虚拟路径,比如一张图片,<img src="/ueditor_upload_file/test.jpg">即可,系统会自动去E:/ueditor_upload_file目录下去寻找test.jpg



此段代码存放位置放在Host标签中,如:

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

<Context docBase="E:/ueditor_upload_file" path="/ueditor_upload_file" reloadable="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"
               prefix="localhost_access_log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />


      </Host>






0 0