代码如下:
package com.ece.common.utils;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
public class GetPropertise2 {
Properties p = null;
public GetPropertise2(String path) {
FileInputStream in;
try {
in = new FileInputStream(new File(path));
p = new Properties();
p.load(in);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public String getProperty(String key) {
if(p == null) {
return null;
}
String property;
try {
property = p.getProperty(key);
// System.out.println( property);
} catch (Exception e) {
return null;
}
return property;
}
public String getProperty(String key, String value) {
if(p == null) {
return null;
}
if (p.getProperty(key) == null) {
return value;
}
return p.getProperty(key);
}
}
package com.ece.manager.web.wxutil;
import com.ece.common.utils.GetPropertise2;
public class ESignTreasureUtil {
static GetPropertise2 getPropertise2 = null ;
// 本地路径:
// D:/eclipse/XM/new-nz-demo/ece-manager/ece-manager-web/src/main/resources/resource/eSignTreasure.properties
// 服务器路径:
// /usr/eqianbao/eSignTreasure.properties
static {
getPropertise2 = new GetPropertise2("D:/eclipse/XM/new-nz-demo/ece-manager/ece-manager-web/src/main/resources/resource/eSignTreasure.properties");
}
public static final String redirectUrl = getPropertise2.getProperty("redirectUrl");// 重定向地址
}
资源文件配置
redirectUrl=请求url