调试时发现不在tomcat的安装目录,
运行下面语句发现,是在eclipse的插件目录的一个web插件目录中
InputStream in = this.getClass().getClassLoader().getResourceAsStream("conn.properties"); Properties properties=new Properties(); properties.load(in); in.close(); System.out.println(properties.getProperty("Driver")); String pathString= this.getServletContext().getRealPath("/WEB-INFO/Classes/conn.propertie"); System.out.println(pathString);