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

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -