[英]Can we read .properties file inside xml?
I have a .properties file that contains the values. 我有一个包含值的.properties文件。 I am trying to set one of the value to a field in xml file.
我正在尝试将值之一设置为xml文件中的字段。 For example session-expiry is set to 300 seconds in property file.
例如,在属性文件中将session-expiry设置为300秒。 So i need to set the same value in the xml file.
所以我需要在xml文件中设置相同的值。
<max-idle-seconds>300</max-idle-seconds>
This 300 should be takem from the .properties file. 该300应该来自.properties文件。 Can anyone help?
有人可以帮忙吗?
Yes. 是。 Add your XML below the code.
在代码下添加您的XML。
<context:property-placeholder location="classpath:your_property_filename.properties" ignore-unresolvable="true"/>
Or you can write: 或者您可以写:
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" lazy-init="false">
<property name="locations">
<list>
<value>classpath:your_property_filename.properties</value>
</list>
</property>
</bean>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.