1. 程式人生 > >讓tomcat伺服器訪問指定磁碟/伺服器 上的靜態資源

讓tomcat伺服器訪問指定磁碟/伺服器 上的靜態資源

 讓tomcat伺服器訪問指定磁碟/伺服器 上的靜態資源

可在tomcat/conf/server.xml中查詢<Host></Host>,在標籤內加入<Context path="/file" docBase="/usr/baidu_tiles" reloadable="true"/>

,如果是磁碟資料夾:<Context path="/file" docBase="D:/baidu_tiles" reloadable="true"/>,再通過localhost:8080/file地址來訪問路境內的檔案;

關於配置之後在idea啟動專案,配置不生效問題,可以開啟tomcat配置頁面,Server選項卡,配置埠號後面的Deploy application configured in Tomcat instance勾選上,問題解決!

參考連結:https://www.zhihu.com/question/35637823