Java read XML configuration parameter code instance


This article mainly introduces the example of Java reading XML configuration parameter code. The example code is introduced in great detail, which has a certain reference learning value for everyone’s study or work. If you need a friend, you can refer to it

paras.xml file

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""
  <! -- default value of administrative division code displayed in foreground -- >
  <property name="zoneCode" value="36"></property>
  <! -- the second generation card reader reads the photo storage location -- >
  <property name="sfzpicpath" value="d:\\"></property>
  <! -- relative path to save ID card photo -- >
  <property name="photoRealPath" value="r/project/imgs/photo/"></property>
</beans> Class file

package com.wisoft.tysfrz.utils;
 *System configuration parameters
 * @author ZHENWENCAN
 *@ date October 9, 2017 1:09:48 PM
public class SysParam {
 //The default value of administrative division code is displayed in the foreground
 private String zoneCode;
 //Second generation card reader reads photo storage location
 private String sfzpicpath;
 //Save relative path of ID card photo
 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();

Reference package required

import org.springframework.context.ApplicationContext;

The above is the whole content of this article, I hope to help you learn, and I hope you can support developer more.

Recommended Today

CSS uses position + margin to realize the horizontal and vertical centering of fixed boxes

margin:auto; + position: absolute; Up, down, left and right: 0Just look at the demo <!DOCTYPE html> <html> <head> <meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″> <meta charset=”utf-8″> <meta name=”viewport” content=”initial-scale=1.0, maximum-scale=1.0, user-scalable=no” /> < title > use position + margin to center the fixed box horizontally and vertically < / Title > <style> body * { outline: 1px […]