2

私は非常に小さな懸念を持っており、かなり長い間グーグルをした後でも答えを見つけることができませんでした。

ディスパッチャサーブレットのweb.xmlで定義されたcontext-paramをどのように使用しますか?

私のweb.xmlでは、次のように定義しています。

<context-param>
    <param-name>root.path</param-name>
    <param-value>/root</param-value>
</context-param>

以下のコード行を使用して、Javaクラスでアクセスできます。

String rootPath = sce.getServletContext().getInitParameter("root.path");

ただし、ディスパッチャサーブレットでこの値を使用する方法がわかりません。以下の場合、値自体よりも/rootの変数を使用したいと思います。

<bean id="propertyConfigurer"
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
        p:location="file:/root/main.properties" />

どんな助けでも大歓迎です。

ありがとうございました。

4

1 に答える 1

3

使ってみて

<bean id="propertyConfigurer"
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
    p:location="file:/#{contextParameters.root.path}/main.properties" />

名前を「root.path」として指定すると問題が発生し、代わりに「root_path」として名前を指定します。

于 2013-03-08T09:57:40.350 に答える