如何访问.properties文件设置的web.xml文件中的过滤器

时间:2010-12-15 15:28:58

标签: ant filter war websphere-6.1

我使用WAS6.1作为服务器(但我想这应该没关系)。我有一个filters.properties文件。它具有键值对(例如config.file.name = / usr / home / config.xml)。这些值在web.xml中使用,如下所示:

<context-param>
  <param-name>config.file</param-name>
  <param-value>@config.file.name@</param-value>
</context-param>

所以我定义了一个build.xml,它使用来自ant的filterset任务来定义所有这些过滤器,但是当我尝试访问主页时,它说无法找到位置@ config.file.name @。显然,这些过滤器没有正确加载。这是我的build.xml代码,它在编译期间定义了过滤器。你觉得我错过了什么?

<target name="compile">
    <property name="compile.target" location="${project.build.dir}/WEB-INF/classes" />

    <property name="project.build.dir.lib" location="${project.build.dir}/WEB-INF/lib" />

    <mkdir dir="${compile.target}" />
    <mkdir dir="${project.build.dir.lib}" />
    <!-- copy the web content into the build location -->
    <copy todir="${project.build.dir}">
        <fileset dir="${web.project.webcontent.dir}" excludes="**/classes/**" />
        **<filterset>
            <filtersfile file="${web.project.src.dir}/filters/${file.filter.name}" />
        </filterset>**

    </copy>

    <!-- compile the java source and put it in the classes directory -->
    <javac classpathref="classpath" srcdir="${web.project.src.dir}" destdir="${compile.target}" debug="${javac.debug}" deprecation="${javac.deprecation}" fork="${javac.fork}" memoryMaximumSize="${javac.memoryMaximumSize}" nowarn="${javac.nowarn}" failonerror="${javac.failonerror}">
    </javac>

    <!-- copy all the non-java resources (properties, etc) into the classes directory-->
    <copy todir="${compile.target}">
        <fileset dir="${web.project.src.dir}">
            <exclude name="**/*.java" />
            <exclude name="filters/**" />
        </fileset>
    </copy>
    <!-- Create a jar file from the ${compile.target} folder  -->
    <jar jarfile="${project.build.dir.lib}/${ant.jar.file}.jar" excludes="filters/**" basedir="${compile.target}" />


</target>

非常感谢您的反馈。

1 个答案:

答案 0 :(得分:0)

感谢您查看我的帖子。它工作正常。主要问题是属性文件的路径不正确。

相关问题