Configure Symlinks for single directory in Tomcat

后端 未结 7 1158
情歌与酒
情歌与酒 2020-12-05 06:55

I have a directory to which a process uploads some .pdf files. This process is out of my control.

I need to make those files available through the websi

7条回答
  •  北荒
    北荒 (楼主)
    2020-12-05 07:37

    There are 4 places where Context can live.

    1. tomcatdir/conf/server.xml
    2. tomcatdir/conf/context.xml
    3. tomcatdir/conf/Catalina/localhost/appname.xml
    4. tomcatdir/webapps/appname/META-INF/context.xml

    In case of tomcat 8 allowlinking attribute should be specified not in Context but in Resources tag. My tomcatdir/conf/context.xml looks like this

    
    WEB-INF/web.xml
    ${catalina.base}/conf/web.xml
     
    
    

    This solution works fine for me now. But I want to share also the mistake I had done before coming to this solution.

    I had defined Resources both in tomcatdir/conf/server.xml and in tomcatdir/conf/context.xml. And allowLinking="true" was set only in tomcatdir/conf/server.xml.

    What I found was that if you do not specify allowLinking it is equal to setting it to false. So I removed Resources tag from server.xml and left it only tomcatdir/conf/context.xml with the allowLinking="true" attribute in it.

提交回复
热议问题