元素类型“servlet”的内容必须匹配“(icon?,servlet-name,display-name ?,

时间:2014-09-25 19:17:00

标签: java servlets web

我知道关于订单,但我已经尝试了所有的可能性, 如果有人可以解释我的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>
    <listener>
        <listener-class>com.ewheelz.SessionCounter</listener-class>
    </listener>
  <servlet>
    <description>This is the description of my J2EE component</description>
    <display-name>This is the display name of my J2EE component</display-name>
    <servlet-name>ConnectionPool</servlet-name>
    <servlet-class>com.ewheelz.ConnectionPool</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>ConnectionPool</servlet-name>
    <url-pattern>/servlet/ConnectionPool</url-pattern>
  </servlet-mapping>
    <welcome-file-list>
        <welcome-file>Home.html</welcome-file>
    </welcome-file-list>

</web-app>

2 个答案:

答案 0 :(得分:0)

更改此

<servlet>
    <description>This is the description of my J2EE component</description>
    <display-name>This is the display name of my J2EE component</display-name>
    <servlet-name>ConnectionPool</servlet-name>
    <servlet-class>com.ewheelz.ConnectionPool</servlet-class>
  </servlet>

对此: -

  <servlet>    
    <servlet-name>ConnectionPool</servlet-name>
    <display-name>This is the display name of my J2EE component</display-name> 
    <description>This is the description of my J2EE component</description>
    <servlet-class>com.ewheelz.ConnectionPool</servlet-class>
  </servlet>

<强> diplay-name and description tag should come after servlet-name tag

答案 1 :(得分:0)

我通过在eclipse中使用设计视图配置servlet和servlet-mapping而不是直接在源视图中的web.xml中键入来解决了这个问题。希望这会有所帮助。