Read the configuration parameters in the xml file and the parameters in the xml file.

Source: Internet
Author: User

Read the configuration parameters in the xml file and the parameters in the xml file.

Paras. xml file

<? 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-bean S-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"> <! -- Default value displayed on the front-end of the Administrative Division code --> <property name = "zoneCode" value = "36"> </property> <! -- The location where the secondary card reader reads the photos --> <property name = "sfzpicpath" value = "d :\\"> </property> <! -- Save the relative path of the ID card photo --> <property name = "photoRealPath" value = "r/project/imgs/photo/"> </property> </bean> </beans>

SysParam. java files

Package com. wisoft. tysfrz. utils;/*** system configuration parameters ** @ author ZHENWENCAN * @ date 1:09:48 on January 1, October 9, 2017 */public class SysParam {// display the default private String zoneCode on the front-end of the Administrative Division code; // private String sfzpicpath; // The relative path of the ID card photo to be read; // The 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 ;}}

Use

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

String photorealpath = sysparam. getPhotoRealPath ();

Package to be referenced

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.