请问在servlet中如何访问init.properties中定义的常量,听高手说要spring注射
哪位高人能指点指点吗

解决方案 »

  1.   

    自己已经搞定,在servlet里面读取这个文件的
     String rootpath =getServletContext().getRealPath("/");
              if (rootpath != null) {
                  rootpath = rootpath.replaceAll("\\\\", "/");
              } else {
                  rootpath = "/";
              }
              if (!rootpath.endsWith("/")) {
                  rootpath = rootpath + "/";
              }
              Properties prop = null;
              try {
                  prop = new Properties();
                  
                  prop.load(new FileInputStream(rootpath
                                  + "WEB-INF/init.properties"));
              } catch (IOException e) {              e.printStackTrace();
              }
              String phpurl= prop.getProperty("phpaddress");