读取xml文件中的配置参数实例
paras.xml文件
SysParam.java类文件
packagecom.wisoft.tysfrz.utils;
/**
*系统配置参数
*
*@authorZHENWENCAN
*@date2017年10月9日下午1:09:48
*/
publicclassSysParam{
//行政区划代码前台显示默认值
privateStringzoneCode;
//二代证读卡器读取照片存储位置
privateStringsfzpicpath;
//保存身份证照片相对路径
privateStringphotoRealPath;
publicStringgetZoneCode(){
returnzoneCode;
}
publicvoidsetZoneCode(StringzoneCode){
this.zoneCode=zoneCode;
}
publicStringgetSfzpicpath(){
returnsfzpicpath;
}
publicvoidsetSfzpicpath(Stringsfzpicpath){
this.sfzpicpath=sfzpicpath;
}
publicStringgetPhotoRealPath(){
returnphotoRealPath;
}
publicvoidsetPhotoRealPath(StringphotoRealPath){
this.photoRealPath=photoRealPath;
}
}
使用
privatestaticApplicationContextcpxac=newClassPathXmlApplicationContext("tysfrz/spring/tysfrz_params.xml");
privatestaticSysParamsysparam=(SysParam)cpxac.getBean("SysParam");
Stringphotorealpath=sysparam.getPhotoRealPath();
需要引用包
importorg.springframework.context.ApplicationContext; importorg.springframework.context.support.ClassPathXmlApplicationContext;
以上这篇读取xml文件中的配置参数实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持毛票票。