问题
after trying to migrate our app from tomcat 7 to tomcat 8 we have found that aliases does not work as before.
Here is a content of context.xml file:
<Context reloadable="true"
aliases="/d1=C://dir1,/d2=C://temp//dir2//,/d3=C://temp//dir3//" >
<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow=".*" />
</Context>
On tomcat 7 I can ropen this urls:
http://localhost:8080/myapp/d2/data.xml
http://localhost:8080/myapp/d3/data.png
On tomcat 8 I get 404 error.
Any idea?
Thanks.
回答1:
I have found a solution. Problem was in context.xml.
To make alias work on tomcat 8 here is required change in context.xml:
<Context reloadable="true" >
<Resources>
<PreResources base="C://dir1" className="org.apache.catalina.webresources.DirResourceSet" webAppMount="/d1" />
<PreResources base="C://temp//dir2//" className="org.apache.catalina.webresources.DirResourceSet" webAppMount="/d2" />
<PreResources base="C://temp//dir3//" className="org.apache.catalina.webresources.DirResourceSet" webAppMount="/d3" />
</Resources>
<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow=".*" />
</Context>
来源:https://stackoverflow.com/questions/25909329/after-migrating-to-tomcat-8-aliases-doesnt-work-any-more