如何从web.xml中的属性文件中读取

fre*_*dev 4 spring web.xml java-ee

在我的web.xml中,我想从属性文件中读取欢迎文件,例如:

<welcome-file-list>
    <welcome-file>${home.page}</welcome-file>
  </welcome-file-list>
Run Code Online (Sandbox Code Playgroud)

我有propertyPlaceholderConfigurer配置:

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

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

            </list>
        </property>
    </bean>
Run Code Online (Sandbox Code Playgroud)

应该在web.xml中添加额外的参数,还是需要定义另一个bean或者是什么?

另外我在web.xml的同一级别上有另一个xml文件(在WEB-INF direclty下)我能以同样的方式从属性文件中读取吗?

请指教.

Dav*_*ton 6

它不像那样工作; 该web.xml文件与Spring 完全无关.

可以做的是拥有一个硬编码的欢迎文件,并在文件中,重定向到Spring配置中定义的内容,通过手动获取Spring上下文来检索页面.