zl程序教程

您现在的位置是:首页 >  Java

当前栏目

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

2023-03-20 14:48:06 时间

1、下载tomcat

2、配置环境变量

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

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	omcatapache-tomcat-10.0.21webapps" unpackWARs="true" autoDeploy="true" 
                    xmlValidation="false" xmlNamespaceAware="false">  
                    
                <!--资源地址-->  <!--  就是访问http://localhost:8089这个地址就是到E://TangRenFileServer//images这个目录下  -->
                <Context path="" docBase="D:filesexpense" debug="0" reloadable="false"/>  
            </Host>  
        </Engine>  
    </Service> 

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


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

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