Java 如何在XMLSpring中正确使用SpEL

Java 如何在XMLSpring中正确使用SpEL,java,spring,Java,Spring,我想用我的资源创建utilbean,使用静态方法创建图像 ClassLoader.getSystemResource 而且 File.separator 她是我的资源地图 <util:map id="ImageFiles" key-type="java.lang.String" value-type="java.lang.String" > <entry key="success" value="#{ClassLoader.getSystemResource

我想用我的资源创建utilbean,使用静态方法创建图像

 ClassLoader.getSystemResource
而且

 File.separator
她是我的资源地图

 <util:map id="ImageFiles" key-type="java.lang.String"  value-type="java.lang.String" >
    <entry key="success" value="#{ClassLoader.getSystemResource("icons"+File.separator+"png"+File.separator+"24x24"+File.separator+"OK.png")}" />
    <entry key="error" value="OptionPane.errorIcon" />
    <entry key="info" value="OptionPane.informationIcon" />
  </util:map>


但是我在Xml中发现了语法错误。可以这样做???

要使用SpEL的静态方法,您应该进一步了解最后一种方法:


确切地说,这是怎么说的;样本如下:

<util:map id="nameToPeriod">
    <entry key="${validation.cycle.units.representation.month}" value="#{T(org.joda.time.Months).ONE}" />
    <entry key="${validation.cycle.units.representation.day}" value="#{T(org.joda.time.Days).ONE}" />
    <entry key="${validation.cycle.units.representation.hour}" value="#{T(org.joda.time.Hours).ONE}" />
    <entry key="${validation.cycle.units.representation.week}" value="#{T(org.joda.time.Weeks).ONE}" />
</util:map>

您应该首先真正熟悉XML。
<util:map id="nameToPeriod">
    <entry key="${validation.cycle.units.representation.month}" value="#{T(org.joda.time.Months).ONE}" />
    <entry key="${validation.cycle.units.representation.day}" value="#{T(org.joda.time.Days).ONE}" />
    <entry key="${validation.cycle.units.representation.hour}" value="#{T(org.joda.time.Hours).ONE}" />
    <entry key="${validation.cycle.units.representation.week}" value="#{T(org.joda.time.Weeks).ONE}" />
</util:map>