标签:inf text eal session puts sys resource cat sysconfig
读取导出jar包的相同目录的配置文件
System.getProperty("user.dir")+"\\"+fileName;
读取类所在目录的配置文件按
InputStreamis=TestAction.class.getClassLoader().getResourceAsStream("test.txt");
web项目读取webcontent
String path = request.getSession().getServletContext().getRealPath("/config/sysconfig.properties"); System.out.println("doGet读取到的/WEB-INF/config/sysconfig.properties:path:"+path); String url = request.getSession().getServletContext().getRealPath("/WEB-INF/config/config.properties"); System.out.println("doGet读取到的/WEB-INF/config/config.properties:url:"+url); /** * 结果: * doGet:path:D:\tomcat7\wtpwebapps\demoProj\config\sysconfig.properties * doGet:url:D:\tomcat7\wtpwebapps\demoProj\WEB-INF\config\config.properties */
标签:inf text eal session puts sys resource cat sysconfig
原文地址:https://www.cnblogs.com/dch0/p/12604663.html