Java 在Tomcat服务器上加载静态文件

Java 在Tomcat服务器上加载静态文件,java,tomcat,directory,Java,Tomcat,Directory,我看到其他人在Tomcat服务器上加载静态文件(例如html)时遇到了一个问题。在a之后,我将添加到server.xml文件中。我一直收到一个404错误。我假设根文件夹是“webapps” 有什么想法吗 目录:webapps/Sprint000/index.htm Server.xml <Engine name="Catalina" defaultHost="localhost"> <Cluster className="org.apache.catalina.h

我看到其他人在Tomcat服务器上加载静态文件(例如html)时遇到了一个问题。在a之后,我将
添加到
server.xml
文件中。我一直收到一个404错误。我假设根文件夹是“webapps”

有什么想法吗

目录:
webapps/Sprint000/index.htm

Server.xml

<Engine name="Catalina" defaultHost="localhost">

      <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>

      <Realm className="org.apache.catalina.realm.LockOutRealm">

        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>

      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">

             Documentation at: /docs/config/valve.html -->

        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />

       <Context docBase="/Sprint000" path="/static" />  
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

      </Host>
    </Engine> 

文档位于:/docs/config/valve.html-->

查找文件
context.xml
,将其编辑为:

<?xml version="1.0" encoding="UTF-8"?>
<Context reloadable="true">
    <Resources>
        <PreResources
            base="F://Sprint000"
            className="org.apache.catalina.webresources.DirResourceSet"
            webAppMount="/static" />
    </Resources>
    <Valve className="org.apache.catalina.valves.RemoteAddrValve"
        allow=".*" />
</Context>


尝试将
docBase=…
更改为绝对路径。仍然是404错误,并且我输入的URL是
http://localhost:8080/static/index.htm
。正确吗?您是否像原始状态一样恢复
server.xml
?(在通过
context.xml
进行配置之前)恢复为原始的
server.xml
文件,并对
context.xml
进行更改。仍然是404错误检查案例:
http://localhost:8080/webapp_name/static/index.htm
。我的解决方案在生产环境(关键任务应用程序,ApacheTomcat8)中工作。我对我的解决方案充满信心。尝试过,但没有成功。我会继续努力,希望我不会砸了我的电脑。谢谢你的时间和帮助!