[Tomcat] tomcat set http file download, configuration file download directory

 

  As the download server of http, there are many ways on the Internet

 

But I think the easiest is: (pro-test works)

  1. Put the file directly in the /var/lib/tomcat6/webapps/ROOT directory,

  2. Then visit the website: http://192.168.2.31:8080/download.zip to download.

 

 

However, if you don't want to put it under webapps/ROOT, you need to configure the directory you want to download: (valid for personal testing)

1. Create an xml file with any file name under the tomcat installation directory \conf\Catalina\localhost, such as: download.xml,

The content is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<Context path="fileDown" reloadable="true" docBase="/opt/downLoadFile" crossContext="true">
</Context>

 

 

 

2. Configure web.xml (tomcat's configuration file), and modify the following configuration (about 105 lines) :

<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>

 

Change the red false to true.

3. Restart tomcat.

4. Visit http://qiaoliqiang.cn/fileDown/2.txt

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324489572&siteId=291194637