java - Spring application context : access web.xml context-params? -


greetings ,

is there way values web.xml context-param spring context?

for example define value in web.xml :

<context-param>   <param-name>compass-index</param-name>   <param-value>file:///home/compass/index</param-value> </context-param> 

and want assign value bean-property as:

<bean ...> <props>   <prop key="compass.engine.connection">     ${from web.xml context-param?}   </prop> </props> </bean> 

thanks in advance?

yes - servletcontextpropertyplaceholderconfigurer

this article explains details. in short, need:

<bean class="org.springframework.web.context.support.servletcontextpropertyplaceholderconfigurer"> </bean> 

and use properties like:

<bean ...>    <property name="compassindex" value="${compass-index}" /> </bean> 

or @value("${compass-index}")


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -