文章来源:嗨学网 敏而好学论坛www.piaodoo.com 欢迎大家相互学习

paras.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:aop="http://www.springframework.org/schema/aop"
 xmlns:tx="http://www.springframework.org/schema/tx"
 xmlns:context="http://www.springframework.org/schema/context"
 xsi:schemaLocation="
   http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
   http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
   http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
   http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">

   <bean id="SysParam" class="com.wisoft.tysfrz.utils.SysParam">
    <!--行政区划代码前台显示默认值-->
    <property name="zoneCode" value="36"></property>
    <!--二代证读卡器读取照片存储位置-->
    <property name="sfzpicpath" value="d:\\"></property>
    <!--保存身份证照片相对路径-->
    <property name="photoRealPath" value="r/project/imgs/photo/"></property>
  </bean>
</beans>

SysParam.java类文件

package com.wisoft.tysfrz.utils;
/**
 * 系统配置参数
 *
 * @author ZHENWENCAN
 * @date 2017年10月9日 下午1:09:48
 */
public class SysParam {
 //行政区划代码前台显示默认值
 private String zoneCode;
 //二代证读卡器读取照片存储位置
 private String sfzpicpath;
 //保存身份证照片相对路径
 private String photoRealPath;
 public String getZoneCode() {
  return zoneCode;
 }
 public void setZoneCode(String zoneCode) {
  this.zoneCode = zoneCode;
 }
 public String getSfzpicpath() {
  return sfzpicpath;
 }
 public void setSfzpicpath(String sfzpicpath) {
  this.sfzpicpath = sfzpicpath;
 }
 public String getPhotoRealPath() {
  return photoRealPath;
 }
 public void setPhotoRealPath(String photoRealPath) {
  this.photoRealPath = photoRealPath;
 }
}

使用

private static ApplicationContext cpxac = new ClassPathXmlApplicationContext("tysfrz/spring/tysfrz_params.xml");
private static SysParam sysparam = (SysParam) cpxac.getBean("SysParam");

String photorealpath = sysparam.getPhotoRealPath();

需要引用包

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

以上这篇读取xml文件中的配置参数实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持敏而好学论坛/嗨学网。

原文地址是:http://www.piaodoo.com/thread-13229-1-2.html 丝袜控www.txdah.com 131www.buzc.org学习之外可赏心悦目有助更好地学习!

读取xml文件中的配置参数实例_java - JAVA的更多相关文章

  1. 【MyBatis学习05】SqlMapConfig.xml文件中的配置总结

    经过上两篇博文的总结,对mybatis中的dao开发方法和流程基本掌握了,这一节主要来总结一下mybatis中的全局配置文件SqlMapConfig.xml在开发中的一些常用配置,首先看一下该全局配置 ...

  2. maven的setting.xml文件中只配置本地仓库路径的方法

    maven的setting.xml文件中只配置本地仓库路径的方法 即:settings标签下只有一个 localRepository标签,其他全部注释掉即可 <?xml version=&quo ...

  3. mapper.xml文件中传入list参数报错 ‘ ’附近有语法错误

    mapper.xml文件中传入list参数,使用foreach循环遍历值,但是在遍历的过程中出错了,具体代码如下所示 mapper.xml <select id="selectByCo ...

  4. .net中读取xml文件中节点的所有属性信息

    功能描述: 将数据以xml的格式记录成配置文件,需要获取配置文件中的数据时,则获取对应的配置文件,读取配置文件里对应节点的所有属性. 逻辑实现: 1.将数据配置好在xml文件中. 2.获取xml文件中 ...

  5. python读取xml文件中的坐标点

    用labelImg工具制作好xml文件后,需要读取其中img路径和坐标点,生成一个label.txt <annotation> <folder>big</folder&g ...

  6. 读取xml文件中节点

    /// <summary> /// /// </summary> /// <param name="xmlpath">节点路径</para ...

  7. Android - 读取XML文件中的数据

    读取XML中存储的数据.将xmlfile.xml存放在assets文件夹中.在activity_main.xml中创建一个textview,用来显示读取到的数据. XML文件内容如下:xmlfile. ...

  8. python中用ElementTree.iterparse()读取xml文件中的多层节点

    我在使用Python解析比较大型的xml文件时,为了提高效率,决定使用iterparse()方法,但是发现根据网上的例子:每次if event == 'end':之后elem.clear()或者是每次 ...

  9. Core3.0读取appsetting.json中的配置参数

    前言 方法很多,下面的例子也是从百度上搜索到的,原文链接已经找不到了. 方法1 1.添加NovelSetting节点,写入相关的配置信息 2.创建类,字段与上面的配置一致 3.StartUp.cs中获 ...

随机推荐

  1. centos 7 ip a 或ifconfig 报command not found

    CentOS 7 下 ifconfig command not found 或 ip command not found 解决办法 首先查看:/sbin/ifconfig   /sbin/ip 是否存 ...

  2. 【HANA系列】SAP ECLIPSE中创建ABAP项目的步骤

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[HANA系列]SAP ECLIPSE中创建AB ...

  3. GIS学习之栅格数据

    栅格数据用一个规则格网来描述与每一个格网单元位置相对应的空间现象特征的位置和取值.在概念上,空间现象的变化由格网单元值的变化来反映.地理信息系统中许多数据都用栅格格式来表示.栅格数据在许多方面是矢量数 ...

  4. 【神经网络与深度学习】caffe+VS2013+Windows无GPU快速配置教程

    首先来一波地址: happynear大神的第三方caffe:http://blog.csdn.net/happynear/article/details/45372231 Neil Z大神的第三方ca ...

  5. Python示例-TCP Port Scan

    import socket import threading # target host address host = "127.0.0.1" # thread list thre ...

  6. Python pymysql对数据库的基础操作

    示例数据库名demo,表名info select * from info; 查看该表数据 +----+-------+--------+-----+---------------------+---- ...

  7. Linux学习大纲(高人整理)

    1.Linux初级 1.1 OS操作系统的原理 1.2 了解常用命令 开机关机 时间管理:date cal clock 1.3 目的结构.目的管理 树形结构 tree cd 1.4 文件管理.文件查找 ...

  8. vue中如何去掉空格

    一.问题 vue中当用户提交表单时,有的数据需要去掉前后空格然后再向后端发送. 二.解决方法 首先可以使用v-model.trim这个v-model修饰符去解决它,但是当用户输入\u200B时,这个方 ...

  9. 一遍记住 8 种排序算法与 Java 代码实现

    ☞ 程序员进阶必备资源免费送「21种技术方向!」 ☜ 作者:KaelQ, www.jianshu.com/p/5e171281a387 1.直接插入排序 经常碰到这样一类排序问题:把新的数据插入到已经 ...

  10. C# 从集合A中取出集合B中不包含的数据(根据ID判断),并添加到集合B中

    从一个集合A中取出另一个集合B中不包含的数据,并添加到集合B中 private void button2_Click(object sender, EventArgs e) { var ListA = ...