English 中文(简体)
是否可能结合环境调查参数在网上使用properties文档?
原标题:Is it possible to use .properties files in web.xml in conjunction with contextConfigLocation parameter?

这里是我网站的一部分:

<context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            classpath:application-config.xml
        </param-value>
</context-param>

申请-没收.xml使用财产地主:

<context:property-placeholder location="classpath:properties/db.properties"/>

是否可以确定哪些财产在网上使用,而不是在应用会议中使用?

最佳回答

是的,您可使用<代码>ServletContextParatiesFactoryBean,以揭露context-param。 价值(也要求完整填写<代码>) PropertyPlaceholderConfigurer ,而不是简单的context:property-placeholder:

<bean id = "myLocation" class = 
    "org.springframework.web.context.support.ServletContextParameterFactoryBean">
    <property name="initParamName" value = "myParameter" />
</bean>

<bean class = 
    "org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location" ref = "myLocation" />
</bean>

Or use Spring 3.0 sEL:

<bean class = 
    "org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location" value = "#{contextParameters.myParameter}" />
</bean>
问题回答

完全同意轴心。 因此,所有胎儿都把最简单的解决办法与春季3.0相结合:

<context:property-placeholder location="#{contextParameters.propertiesLocation}"/>

iii

<context-param>
   <param-name>propertiesLocation</param-name>
   <param-value>classpath:properties/db.properties</param-value>
</context-param>

页: 1





相关问题
array dependency injection in spring?

is there a way to use dependency injection to inject all available implementations of a specific interface in spring? This is kind of the same thing as asked here for .NET. Though my aim is to use @...

Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Grails Packaging and Naming Conventions

Packaging Controllers, Services,etc. i.e. - com.company.controllers - com.company.services Is this a good practice or should be avoided by all means?? Another worth mentioning problem I encountered ...

How can I determine Objects in application context?

I am trying to write a portlet for Liferay (using Tomcat and Spring) and need to use a database via Persistence API/Hibernate. I am using some configuration XMLs (applicationContext.xml, etc.) and ...

How to prevent JPA from rolling back transaction?

Methods invoked: 1. Struts Action 2. Service class method (annotated by @Transactional) 3. Xfire webservice call Everything including struts (DelegatingActionProxy) and transactions is configured ...

热门标签