tomcat搭建本地文件服务器(windows版本)

1、下载tomcat

2、配置环境变量

在“我的电脑”(右键)->“属性”->“高级属性设置”->“环境变量”-“系统属性”-“系统变量”中添加TOMCAT_HOME=D:\apache-tomcat-9.0.50(此路径为你解压文件夹所在的绝对路径)
在CLASSPATH中最后添加%TOMCAT_HOME%\lib\servlet-api.jar;
在Path中最前添加%TOMCAT_HOME%\bin;
具体配置详情百度即可

3、修改conf路径下server.xml配置文件

添加如下内容
<!-- A "Service" is a collection of one or more "Connectors" that share
       a single "Container" Note:  A "Service" is not itself a "Container",
       so you may not define subcomponents such as "Valves" at this level.
       Documentation at /docs/config/service.html
   -->
   
    <Service name="newtest">  
        <!--分配8089端口 -->  
        <Connector port="8089"   
                   protocol="HTTP/1.1"  
                   connectionTimeout="20000"   
                   URIEncoding="UTF-8"  
                   redirectPort="8443" />          
                   
        <Engine name="newtest" defaultHost="localhost">  
            <!--name为项目访问地址 此配置的访问为http://localhost:8089 appBase配置tomcat下wabapps下的路径-->  
            <Host name="localhost" appBase="D:\install\tomcat\apache-tomcat-10.0.21\webapps" unpackWARs="true" autoDeploy="true" 
                    xmlValidation="false" xmlNamespaceAware="false">  
                    
                <!--资源地址-->  <!--  就是访问http://localhost:8089这个地址就是到E://TangRenFileServer//images这个目录下  -->
                <Context path="" docBase="D:\files\expense" debug="0" reloadable="false"/>  
            </Host>  
        </Engine>  
    </Service> 

此时通过localhost:8089访问的就是 本地的路径 D:\files\expense


注意:cmd窗口中文乱码解决

进入到tomcat的安装目录D:\install\works\apache-tomcat-8.5.70\conf,打开logging.properties文件,将UTF-8格式改成GBK即可。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章