jsp頁面調用WEB-INF下的.properties文件

1、在WEB-INF下面建立.properties文件,假如命名爲resource.properties,假如內容如下:

<span style="font-size:18px;">upload.video.path=D:\\emc_at\\streams\\
upload.xml.path = D:\\emc_at\\coursedescription\\</span>

2、jsp中讀取配置文件
<span style="font-size:18px;">try {
    //讀取配置文件
    Properties pro = new Properties();
    String realpath = request.getRealPath("/WEB-INF/");
    FileInputStream fis = new FileInputStream(realpath + "/resources.properties");
    pro.load(fis);	
    }catch (Exception e) {
       e.printStackTrace();
    }</span>

3、使用裏面的內容

<span style="font-size:18px;">String savePath =  pro.getProperty("upload.video.path");</span>


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章