Some pit tomcat path mapping configuration

This article is a personal reference other blog with their own personally tested, to draw some conclusions and then share with you more, people want to explore a little pit.


A conventional method (Method a): 
%% Tomcat / the conf / the server.xml file, add the tag

<Host>
<Context docBase="D:/upload/test/savePath1" path="/mapperUrl"/>
<!--其中docBase为实际文件存储路径,这里由于是非window系统,所以实际存储路径没有硬盘首字母,path为映射路径-->
</Host>

So when developed, will be the back-end [/ mapperUrl / filename] back to the front, the front end of this as a url, you can access to [D: / upload / test / savePath1 / filename] resources under.

 

But try the above manner according to the configuration, found or can not access resources through the images to map the path, according to online information, the reason may:

  1. docBase path and the path name can not be the same;
  2. conf / web.xml listings provided is true, the object is a virtual path. Formal operation of the project must be switched off. (I tried, or not)
    <servlet>
        <servlet-name>default</servlet-name>
        <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
        <init-param>
            <param-name>debug</param-name>
            <param-value>0</param-value>
        </init-param>
        <init-param>
            <param-name>listings</param-name>
            <param-value>false</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

  

We plan to address this problem, Method II

Path:% tomcat% / conf / Catalina  / localhost /
program: Create xml file under this path, the file name you want to visit Path path (ie path = "" value), written to the actual storage address within the xml file. 
example: Create a file for the mapperUrl.xml, reads as follows:

<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="D:/360Downloads" reloadable="true"></Context>

And then configure the virtual path to become effective.

 

 

IDEA configuration file to map the path of some of the differences:

Since the switch IDEA, where virtual path coupled configuration (when only the development), or have the configuration according to the above embodiment tomcat deployment server

The following configuration equivalent to setting specifies the virtual path in tomcat configuration file

 

 

Published 21 original articles · won praise 9 · views 30000 +

Guess you like

Origin blog.csdn.net/a5552157/article/details/81203312