Concatenate strings within a Spring XML configuration file?

前端 未结 1 542
不思量自难忘°
不思量自难忘° 2020-12-31 03:04

I have a String value in a Spring configuration file that comes to be as the result of a JNDI lookup -- it happens to be a path name:

相关标签:
1条回答
  • 2020-12-31 03:55

    Try using Spring EL (expression language). I would try the following (not tested):

    <jee:jndi-lookup id="myAppHomeDir" jndi-name="myAppHomeDir" />
    
    <bean id="LogPath" class="org.mystuff.initBean">
        <property name="logDirectory" value="#{myAppHomeDir+'/logs'}"/>
    </bean>
    

    Not quite sure if it would work. The thing that troubles me is the cast from File (I guess) to String when concatenating. So if the previous one didn't work, I would try:

    #{myAppHomeDir.canonicalPath+'/logs'}
    

    Let us know if it works.

    0 讨论(0)
提交回复
热议问题