getProperty(String key) 獲取指定鍵指示的系統屬性(從系統環境或*.properties等配置文件中讀取key對應的值)。this
getProperty(String key, String def) 獲取用指定鍵描述的系統屬性(從系統環境或*.properties等配置文件中讀取key對應的值,當key值爲NULL時,返回def的值; 當key值不爲NULL時,返回key的值 )。spa
1.public static String getProperty(String key, String def) {get
SecurityManager sm = getSecurityManager();it
if (sm != null) {配置
sm.checkPropertyAccess(key);coding
return props.getProperty(key, def);配置文件
//當getProperty(key);爲null時,返回defaultValue(即便傳入的def值)static
public String getProperty(String key, String defaultValue) {di
String val = getProperty(key);文件
return (val == null) ? defaultValue : val;
private String encoding = "GBK";
public JavaModel(Map<String, ?> environment)
super(environment);
//mod.encoding爲system.properties配置文件中設置的鍵值對
this.encoding = System.getProperty("mod.encoding", this.encoding);