2011-12-19 4 views
1

줄무늬를 사용하고 있습니다. 일부 구성에서는 응용 프로그램 시작시 사용할 매개 변수를 추가하기 만하면됩니다. 가장 간단한 방법은 무엇입니까? 특성, web.xml 또는 무엇? 나는 줄무늬 책 (또한 웹 사이트)을 찾았지만 분명한 대답을 찾을 수 없었다.줄무늬가있는 간단한 응용 프로그램 구성

나는 일반적으로이 같은 appConfig.properties 파일과 리스너 클래스 사용하십시오 :

public class ConfigLoader implements javax.servlet.ServletContextListener { 

public void contextInitialized(ServletContextEvent sce) { 
    Properties properties = System.getProperties(); 
    properties.put(sce, sce); 
    try { 
     properties.load(this.getClass().getResourceAsStream("appConfig.properties")); 
     System.out.println(this.getClass().getResource("").getFile()); 

    } catch (IOException ex) { 
     throw new ExceptionAdapter(ex); 
    }   
} 

public void contextDestroyed(ServletContextEvent sce) { 
    throw new UnsupportedOperationException("Not supported yet."); 
} 

}

답변

3

줄무늬의 좋은 점은을 그것이 바인딩 등의 작은 세계의 이상, 그것을 큰 발자국은 없다. 그래서 당신은 당신이 원하는 무엇이든 할 수 있습니다. appConfig.properties가 만족 스러우면 계속 사용하십시오.