Springアプリケーションコンテキスト:アクセスのweb.xmlコンテキストのparams?
質問
ご挨拶、
Springコンテキストにweb.xmlのコンテキスト-PARAMから値を取得する方法はありますか?
例えば私はweb.xmlの値を定義します
<context-param>
<param-name>compass-index</param-name>
<param-value>file:///home/compass/index</param-value>
</context-param>
そして私はと豆プロパティにその値を割り当てるます:
<bean ...>
<props>
<prop key="compass.engine.connection">
${from web.xml context-param?}
</prop>
</props>
</bean>
事前のおかげで?
解決
はい - ServletContextPropertyPlaceholderConfigurer
する
<bean class="org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer">
</bean>
その後、などのプロパティを使用します:
<bean ...>
<property name="compassIndex" value="${compass-index}" />
</bean>
または@Value("${compass-index}")
と
所属していません StackOverflow