简体   繁体   中英

How to access folder in tomcat server using relative path of it?

I have one folder which has some PDF files which is used by my application, but when I include this folder in my war file , the size of war file increase to GBzz , so I thought of keeping this folder in some server location , build and deploy the war without the folder which will have the relative path of this folder , can any one help me on this? I am not sure how to do configuration for this to read the folder ?I am using tomcat server.

The easiest way starting from Tomcat 7 is to configure alias paths ie paths on the disk that will be aliased in Tomcat. Check this section in the guide for aliases attribute. You want something like this in your server.xml:

<Context docBase="AppName" path="/appname" aliases="/pathPdf=c:\pdfs"/>

In case you're on an older Tomcat, your best bet is to setup a servlet that will serve files from the desired external location.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM