web.xml版本控制

Lea*_*ner 5 eclipse java-ee

我正在Eclipse中构建一个Web应用程序,并在以下版本中遇到版本问题web.xml:

<web-app version="2.4" xmlns="java.sun.com/xml/ns/javaee"
   xmlns:xsi="w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="java.sun.com/xml/ns/javaee java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
Run Code Online (Sandbox Code Playgroud)

错误是:

cvc-enumeration-valid: Value '2.4' is not facet-valid with respect to enumeration '[2.5]'.
It must be a value from the enumeration.
Run Code Online (Sandbox Code Playgroud)

项目方面显示了动态Web模块和Servlet API的2.4版本.

JB *_*zet 8

如果你在Eclipse中声明你的应用程序是一个2.5应用程序,并说你的web-app版本是2.4,但链接到2.5版本的模式(web-app_2_5.xsd),它显然不会工作

<web-app version="2.4" 
         xmlns="java.sun.com/xml/ns/javaee"
         xmlns:xsi="w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="java.sun.com/xml/ns/javaee 
                             java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
                                                                 ^-- HERE!
Run Code Online (Sandbox Code Playgroud)

使用2.4版本:

<web-app version="2.4" 
         xmlns="http://java.sun.com/xml/ns/j2ee" 
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
                             http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
Run Code Online (Sandbox Code Playgroud)