What is the best place to store a configuration file in a Java web application (WAR)?

后端 未结 6 1579
猫巷女王i
猫巷女王i 2020-12-23 01:54

I create a web application (WAR) and deploy it on Tomcat. In the webapp there is a page with a form where an administrator can enter some configuration data. I don\

6条回答
  •  借酒劲吻你
    2020-12-23 02:21

    WEB-INF is a good place to put your config file. Here's some code to get the absolute path of the directory from a servlet.

    public void init(ServletConfig servletConfig) throws ServletException{
        super.init(servletConfig);
        String path = servletConfig.getServletContext().getRealPath("/WEB-INF")
    

提交回复
热议问题