简体   繁体   中英

How to correct use SpEL in XML Spring

I would like to create util bean with my resources to images using static method

 ClassLoader.getSystemResource

and also

 File.separator

her is my util resource map

 <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>

But i got parse syntax error in Xml. It is possible to do it something like this??

要使用SpEL的静态方法,您应该学习有关最后一个方法的更多信息:

<entry key="success" value="#{T(com.my.proj.pack.ClassLoader).getSystemResource("icons"+File.separator+"png"+File.separator+"24x24"+File.separator+"OK.png")}" />

Exactly, how it was said earlier; Sample below:

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM