Mapping a directory outside the web-app to URL in TOMCAT

后端 未结 3 805
难免孤独
难免孤独 2020-12-08 00:53

I need to map an directory containing images which resides outside tomcat webapps folder, so that application can serve those images.

I am making a J2EE Web applicat

3条回答
  •  既然无缘
    2020-12-08 01:32

    I had the same issue but found a solution.

    If you are using Eclipse and a Tomcat plugin then please note that the Eclipse Tomcat plugin creates a separate CATALINA_BASE under the Eclipse workspace directory.

    You can go to this location and you will find server.xml. Use that server.xml and it will work.

    My actual tomcat directory is:

    C:\apache-tomcat-7.0.62x64\apache-tomcat-7.0.62\conf
    

    and my Eclipse Tomcat server uses:

    C:\workspace\JSF\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf 
    

    Use the workspace path and server.xml from this location.

    Add this in server.xml inside the host tag:

    < Context docBase="D:/personal"  path="/images" />
    

    and it will work if D:/personal has 1.png, and then the url http://localhost:8080/images/1.png will load the image.

提交回复
热议问题