0

我正在使用 JSF 2.0 和 Spring 3.1 构建应用程序。在春季应用程序上下文文件中,我正在设置一个属性XMLOutputFilePath

Spring ApplicationContextFile : 

<bean id="placeholderConfig"
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>/WEB-INF/classes/config.properties</value>
            </list>
        </property>
    </bean>
    <bean id="DetailsBean"
            class="sections.DetailsBeanFactory"
            factory-method="createInstance">
            <constructor-arg index="0" value="${XMLOutputFilePath}" />
        </bean>

首次部署应用程序时,我正在从 config.property 文件中读取XMLOutputFilePath

JSF Bean 代码:

for (String filePath : _filePathList) {
                    System.setProperty("XMLOutputFilePath", filePath);
                    System.out.println("For file : " + filePath);
                    _context = new ClassPathXmlApplicationContext("WEB-INF/applicationContext.xml");
//Some code here
                }

我想在我的 JSF Bean 类中做两件事:

  1. 我有一个文件路径列表,我想用这个新路径更改每个新文件路径的XMLOutputFilePath值。(可以在代码中看到..)
  2. 使用这个新的属性值重新加载上下文。

我正在尝试以这种方式执行此操作,但它不起作用。它不会更改 *XMLOutputFilePath** 值,也不会读取上下文文件。

我怎样才能做到这一点?

4

0 回答 0