日期:2014-05-20  浏览次数:20672 次

getResourceAsStream 问题大家来看看,
InputStream   is   =   Test1.class.getClassLoader().getResourceAsStream( "/db.property ");db.property放web-inf   class下面,怎么就是读不出来

------解决方案--------------------
你可以使用以下代码试一下:
InputStream is = Test1.class.getResourceAsStream( "db.property ");
主要是要把getClassLoader()去掉。

如果还不行,那就需要把db.property文件放在与Test1.class相同的包下就可以了。