After migrating to tomcat 8 aliases doesn't work any more

自闭症网瘾萝莉.ら 提交于 2019-12-04 04:45:57

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!