我遇到其他人在Tomcat服务器上加载静态文件(例如html)时遇到的问题。在guide on accessing local files from a tomcat server之后,我已将<Context docBase="F:/Sprint000" path="/static" />
添加到server.xml
文件中。我一直收到404错误。我假设根文件夹是`webapps&#39;?
有什么想法吗?
指南: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 "%r" %s %b" />
</Host>
</Engine>
答案 0 :(得分:0)
查找文件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>