首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Properties 路径设置-servlet上的设置

2012-12-20 
Properties 路径设置--servlet下的设置//根据key读取valuepublic String readValue() { // 返回Servlet上

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";      }}

热点排行