我在spring使用加载属性
<util:properties id="myProperties" location="classpath:/myprops.properties" />
然后在配置中,我使用“ freemarkerVariables”属性,例如
<bean id="abstractFreemarkerConfig" abstract="true">... <property name="freemarkerVariables" ref="staticAttributesMap" /><util:map id="staticAttributesMap"> <entry key="var1" value="${var1}" /> <entry key="var2" value="${var2}" /> <entry key="myMap"> <map> <entry key="v1" value="${value1}" /> <entry key="v2" value="${value2}" /> </map> </entry></util:map>其中var1 / var2 / value1 / value2是文件中的所有属性。
您可以像这样在freemarker中访问属性
$var1$$var2$$myMap.v1$$myMap.v2$
此解决方案的唯一缺点是,Freemarker无法自动使用属性。您需要添加所需的内容。



