创建 servlet 时出现“不支持 Web 应用程序版本”

BeM*_*his 2 java jsp netbeans servlets web-applications

我正在关注教程http://javanetbeans.net78.net/kb/60/web/tutorial-webapps.html

当我到达“使用 servlet 创建前端控制器”部分时,我收到来自 Netbeans 的错误消息,指出“不支持 Web 应用程序版本”

使用 netbeans 6.8

任何人都能够解释为什么我收到这个提示?

这是我的 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 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns="http://java.sun.com/xml/ns/javaee"
     xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
     id="/Midnight" version="2.5">
  <session-config>
    <session-timeout>30</session-timeout>
  </session-config>
</web-app>
Run Code Online (Sandbox Code Playgroud)

Jim*_*ugh 5

查看为<web-app>web.xml 文件元素中的“version”属性设置的值。以下是 2.5 版 Web 应用程序的示例:

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns="http://java.sun.com/xml/ns/javaee"
     xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
     id="WebApp_ID" version="2.5">
    <!-- The rest of your web.xml content -->
</web-app>
Run Code Online (Sandbox Code Playgroud)

也许您的设置为容器不支持的其他内容。