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

发布于 2024-10-07 22:40:37 字数 2107 浏览 0 评论 0原文

我使用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 的过滤器集任务来定义所有这些过滤器,但是当我尝试访问主页时,它说无法找到位置 @配置.文件.名称@。显然,这些过滤器没有正确加载。这是我的 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>

非常感谢您的反馈。

I am using WAS6.1 as the server(but I guess this should not matter).I have a filters.properties file. It has key value pair (e.g. config.file.name=/usr/home/config.xml). These values are being used in web.xml as shown below:

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

So I have defined a build.xml which uses filterset task from ant to define all those filters but when I try to access the home page it says that not able to find location @config.file.name@. Obviously, these filters are not being loaded properly. Here is my build.xml code which defines the filters during the compilation. What do you think I am missing?

<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>

Your feedback is highly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦里的微风 2024-10-14 22:40:37

感谢您查看我的帖子。它运行良好。主要问题是属性文件的路径不正确。

Thanks for looking at my post. It is working fine. The main issue was that the path to the properties file was not correct.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文