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
Post a Comment