今天复习servlet写登陆页面发现这个错误,在获取db.properties输入流时,明明点击配置文件能够自动跳转,我一直以为路径是对的,后来在网上查找才知道
获取db.properties输入流时
Properties ps = new Properties(); 读取的配置文件db.properties应该在resources目录下 InputStream is = DBUtils.class.getClassLoader().getResourceAsStream("db.properties");
Properties ps = new Properties(); 读取的配置文件db.properties应该和连接池类在同一个package下 InputStream is = DBUtils.class.getResourceAsStream("db.properties");
再记不住咣咣给自己两拳