读取资源


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);
    }
}