fresh_dev
fresh_dev

Reputation: 6774

How to read from property file in web.xml

in my web.xml i want to read the welcome file from property file something like:

<welcome-file-list>
    <welcome-file>${home.page}</welcome-file>
  </welcome-file-list>

i have propertyPlaceholderConfigurer configured:

<bean id="propertyPlaceholderConfigurer"
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>

                <value>classpath:messages/application.properties</value>

            </list>
        </property>
    </bean>

is there's additional param should be added to web.xml, or another bean needs to be defined or what ?

also i have another xml file on the same level of web.xml (under WEB-INF direclty) can i read from property file in it in the same way ?

please advise.

Upvotes: 4

Views: 2457

Answers (1)

Dave Newton
Dave Newton

Reputation: 160201

It doesn't work like that; the web.xml file is completely unrelated to Spring.

What you could do is have a hard-coded welcome file, and inside that file, redirect to something defined in the Spring configuration, retrieving the page by grabbing the Spring context manually.

Upvotes: 6

Related Questions