读书人

Properties 路径设置-servlet上的设置

发布时间: 2012-12-20 09:53:21 作者: rapoo

Properties 路径设置--servlet下的设置

//根据key读取valuepublic String readValue() { // 返回Servlet上下文路径。 String filePath = "/config/paper.properties"; String key = "pvalue";          String path = this.getServletContext().getRealPath("/");         path = path.substring(0, path.length() - 1);         path = path + "/WEB-INF/classes"+filePath;                  System.out.println("path===============1"+path);     Properties prop = new Properties();     try {        FileInputStream input = new FileInputStream(path);        prop.load(input);            String value = prop.getProperty (key);            return value;        } catch (Exception e) {           e.printStackTrace();           return "50";      }}

读书人网 >编程

热点推荐