To configure Tomcat To access files from other places ( stay tomcat Configure the virtual mapping file path in )

  • Simple — One file at a time
  • Single access to the entire directory


Simple — One file at a time

If it's just like accessing a file , Here's the picture :
 Insert picture description here

It just needs to be modified tomcat Under the installation path conf Under folder server.xml that will do , The modification method is very simple ;
find sercer.xml file :
 Insert picture description here

stay ( At the end of the file ) Add the following code to the tag :

<!--  Access file virtual path settings  --><Context path="/test" docBase="D:\other\Tomcat\tomcat6\file" crossContext="true"></Context>

explain :

  • docBase: Its value means that the virtual mapping path points to the local computer you want to access ( Or the server ) The directory of the file on the ( Be careful , Don't add... To the name of the file you want to access );
  • path: The value is when you enter the path in the browser ( He's like an alias , Generation refers to docBase A list of addresses for );
  • crossContext: The value is true It means that the configuration is different context Share a session;

After the restart tomcat, Input ( Take the above configuration as an example ):https://192.168.225.241:8443/test/a.txt that will do ;


Single access to the entire directory

 Insert picture description here

On top of that , You need to configure conf Under folder web.xml file ;
 Insert picture description here

find web.xml Of documents   label , The inside listings from false Change to true that will do ;

<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>true</param-value></init-param><load-on-startup>1</load-on-startup></servlet>

restart tomcat, browser url Column input :https://192.168.225.241:8443/test, You can see the effect ;