[CMS properties]
cmsServerName=cms
cmsTemplateDirectoryName=template
[time out:minute]
time_out=300000
[administrator setting]
administrator=SA
admingroup=ADMINROLE
[web path setting]
innerresource=/AccessControl/jsp/innerresource/
[picture path setting]
picturePath=C:/picture/
[log path setting]
logPath=c:/log1/
package creator.config;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
public class ConfigBundle {
private static ResourceBundle bundle;
public ConfigBundle() {}
public static String getString(String s) {
String s1 = null;
try {
s1 = getResourceBundle().getString(s);
} catch (MissingResourceException e) {
System.out.println("ConfigBundle:getString error!" + e.toString());
}
return s1;
}
private static ResourceBundle getResourceBundle() {
if (bundle == null)
bundle = ResourceBundle.getBundle("creator.config.config");
return bundle;
}
}
說明:使用 ResourceBundle 載入同包下 config.properties (基名 creator.config.config),提供靜態 getString(key) 方法讀取值,捕獲缺失資源異常並輸出錯誤訊息。