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即可。

 

posted @ 2022-05-27 16:14  佛祖让我来巡山  阅读(469)  评论(0编辑  收藏  举报

佛祖让我来巡山博客站 - 创建于 2018-08-15

开发工程师个人站,内容主要是网站开发方面的技术文章,大部分来自学习或工作,部分来源于网络,希望对大家有所帮助。

Bootstrap中文网