读取资源

public class demo01 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        InputStream is=this.getServletContext().getResourceAsStream("/WEB-INF/classes/db.jdbc");
        Properties properties= new Properties();
        properties.load(is);
        String acc=properties.getProperty("account");
        String pwd=properties.getProperty("password");
        resp.getWriter().print(acc+"-----"+pwd);
    }
}

 

posted @ 2021-12-12 21:39  小魏同学呀  阅读(26)  评论(0)    收藏  举报