应该把属性文件放在web-inf/classes下面
然后你读取文件的时候用InputStream is = getClass().getClassLoader().getResourceAsStream(fileName);
然后你读取文件的时候用InputStream is = getClass().getClassLoader().getResourceAsStream(fileName);
解决方案 »
- Hibernate property lazy load问题
- 用Spring不能再用new了?
- 关于SPRING嵌套数据绑定的问题。
- 这个问题该怎么解决。?关于JDBC
- Unable to instantiate Action, messageAction, defined for 'message_browseMessage
- 关于WEBLOGIC错误LOG信息分析,求高手指点~~~~~~
- axis用户验证求教
- tapestry的template和page的放置不能有层次么?
- j2ee编写ejb的时候,InitContext()方法要进行初始化加协议和url地址,如何来写?急!急!急!急!急!急!急!急!急!急!急!急!急!急!急!急!急!急!急!急!急!急!急!急!
- 看看创建多少对象
- 用axis作webservice,通过wsdl2java之后,怎么写客户端程序?
- 请问JTable加数据时,怎么控制从上往下加或者是从下往上加
环境变量都设好了,都会出现这样的问题(tomcat 4.x)的
具体指向哪里你自己试试看吧
String rootPath = getServletContext().getRealPath("/");
File file = new File(rootPath+"\\WEB-INF\\classes\\a.properties");
InputStream ins = new FileInputStream(file);
byte[] b = new byte[1024];
while ((ins.read(b))!=-1) {
out.print(new String(b));
}
其中rootPath就是webModule的根目录。
:
1 应该把属性文件放在web-inf/classes下面
2 然后你读取文件的时候用InputStream is = getClass().getClassLoader().getResourceAsStream(fileName);