我正在开发一个 Java EE 项目。我想在我的 JSP 页面中添加一个图表,所以我搜索并找到了“AnyChart.jar”库。当我想在 JSP 中使用它时,我需要将一些信息写入 web.xml 部署描述符。我的描述符应该看起来像这样才能正常工作:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<filter>
<filter-name>AnyChart Resources</filter-name>
<display-name>AnyChart static resources filter</display-name>
<description>
This servlet filter is intended for catch http request
to static AnyChart Component resources (AnyChart.js and AnyChart.swf)
</description>
<filter-class>com.anychart.servlet.ResourceFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>AnyChart Resources</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
但我已经在描述符中有一些信息:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<servlet>
<servlet-name>LoginServlet</servlet-name>
<servlet-class>servlets.LoginServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>Configuring</servlet-name>
<servlet-class>servlets.Configuring</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>LoginServlet</servlet-name>
<url-pattern>/LoginServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Configuring</servlet-name>
<url-pattern>/Configuring</url-pattern>
</servlet-mapping>
</web-app>
我的问题:如何合并这两个文件以使其正常工作?我试图像这样合并它,但它不起作用:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<servlet>
<servlet-name>LoginServlet</servlet-name>
<servlet-class>servlets.LoginServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>Configuring</servlet-name>
<servlet-class>servlets.Configuring</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>LoginServlet</servlet-name>
<url-pattern>/LoginServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Configuring</servlet-name>
<url-pattern>/Configuring</url-pattern>
</servlet-mapping>
<filter>
<filter-name>AnyChart Resources</filter-name>
<display-name>AnyChart static resources filter</display-name>
<description>
This servlet filter is intended for catch http request
to static AnyChart Component resources (AnyChart.js and AnyChart.swf)
</description>
<filter-class>com.anychart.servlet.ResourceFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>AnyChart Resources</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
</web-app>