我有一个 web.xml,其中定义了大约 10 个 servlet,并定义了一些基本配置,如下所示:
<servlet>
<servlet-name>dummyServlet</servlet-name>
<servlet-class>com.abc.Servlet</servlet-class>
<init-param>
<param-name>target</param-name>
<param-value>foo.com</param-value>
</init-param>
<init-param>
<param-name>log</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>dummyServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>dummyServlet2</servlet-name>
<servlet-class>com.abc.Servlet2</servlet-class>
<init-param>
<param-name>target</param-name>
<param-value>foo.com</param-value>
</init-param>
<init-param>
<param-name>log</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>dummyServlet2</servlet-name>
<url-pattern>/dummy</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>actualServlet</servlet-name>
<servlet-class>com.abc.ActualServlet</servlet-class>
<init-param>
<param-name>target</param-name>
<param-value>foo.com</param-value>
</init-param>
<init-param>
<param-name>log</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>dummyServlet</servlet-name>
<url-pattern>/actual</url-pattern>
</servlet-mapping>
现在,根据某些条件,从我的 ant 目标中,我需要删除两个 dummy-servlet 及其映射,但需要保留实际 servlet 及其映射。有人可以建议最好/最简单的方法吗?我应该使用ant <replace>
xmltask 还是其他一些功能?替换整个 web.xml 不是一种选择。