Spring 如何读取web.xml中的属性文件
在myweb.xml中,我想从属性文件中读取欢迎文件 比如:Spring 如何读取web.xml中的属性文件,spring,jakarta-ee,web.xml,Spring,Jakarta Ee,Web.xml,在myweb.xml中,我想从属性文件中读取欢迎文件 比如: <welcome-file-list> <welcome-file>${home.page}</welcome-file> </welcome-file-list> ${home.page} 我已配置了PropertyPlaceHolderConfigure: <bean id="propertyPlaceholderConfigurer" cla
<welcome-file-list>
<welcome-file>${home.page}</welcome-file>
</welcome-file-list>
${home.page}
我已配置了PropertyPlaceHolderConfigure:
<bean id="propertyPlaceholderConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:messages/application.properties</value>
</list>
</property>
</bean>
类路径:messages/application.properties
是否有其他参数应该添加到web.xml,或者需要定义另一个bean,或者什么
我还有另一个与web.xml相同级别的xml文件(在web-INF目录下)
我可以用同样的方法从属性文件中读取吗
请告知。它不是那样工作的;
web.xml
文件与Spring完全无关
你可以做的是有一个硬编码的欢迎文件,在该文件中,重定向到Spring配置中定义的内容,通过手动获取Spring上下文来检索页面。所以,没有办法从web.xml内的属性文件读取值?@fresh\u dev我不知道是否绝对没有办法,但是装载
web.xml
的是容器,默认情况下,容器对Spring一无所知。我说的不仅仅是spring,我说的是一般性的,如果有一种方法,那就是为什么我标记了javaee.btw,你知道如何在web inf(url重写文件)下从另一个.xml文件中读取属性文件吗@fresh_dev如果您使用的是构建系统,那么可以使用各种机制静态重写web.xml。对于加载时替换,我认为您可能可以指定-D
启动属性,但这显然不是来自配置文件,我不确定它是否是跨容器的。