SmileFace
与java一起走过的日子
posts - 41,  comments - 8,  trackbacks - 0

这2天tomcat总是出问题,不能正常启动,错误如下: org.xml.sax.SAXParseException: The content of element type "web-app" must match "(icon?,display-name?,description?,distributable?,context-param*,filter*,filter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mapping*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,security-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-local-ref*)".

后来发现原因竟然和DTD 的格式要求有关,原文在:

我copy了基本要点:

===================================================

So for the 2.3 version of the DTD, you have to put the tags in the correct order. You have:
<web-app>
  <servlet></servlet>
  <servlet-mapping></servlet-mapping>
  <servlet></servlet>
  <servlet-mapping></servlet-mapping>
  <servlet></servlet>
  <servlet-mapping></servlet-mapping>
  <!-- ... -->
  <listener></listener>
</web-app>


But the DTD says it must be:
<web-app>
  <listener></listener>
  <servlet></servlet>
  <servlet></servlet>
  <servlet></servlet>
  <!-- ... -->
  <servlet-mapping></servlet-mapping>
  <servlet-mapping></servlet-mapping>
  <servlet-mapping></servlet-mapping>
  <!-- ... -->
</web-app>

======================================

The error message tells you the order they must be in:

 content of element type "web-app" must match "(icon?,display-name?,description?,distributable?,context-param*,
filter*,filter-mapping*,listener*,servlet*,servlet-mapping*,
session-config?,mime-mapping*,welcome-file-list?,error-page*,
taglib*,resource-env-ref*,resource-ref*,security-constraint*,
login-config?,security-role*,env-entry*,ejb-ref*,ejb-local-ref*)"

Means the order is:
icon (0 or 1 times)
display-name (0 or 1 times)
description (0 or 1 times)
distributable (0 or 1 times)
context-param (0 or more times)
filter (0 or more times)
filter-mapping (0 or more times)
listener (0 or more times)
servlet (0 or more times)
servlet-mapping (0 or more times)
session-config (0 or 1 times)
mime-mapping (0 or more times)
welcome-file-list (0 or 1 times)
error-page (0 or more times)
taglib (0 or more times)
resource-env-ref (0 or more times)
resource-ref (0 or more times)
security-constraint (0 or more times)
login-config (0 or 1 times)
security-role (0 or more times)
env-entry (0 or more times)
ejb-ref (0 or more times)
ejb-local-ref (0 or more times)

==============================

i also want to know that
are tags supposed to be in some order in version 2.4, or i can have them in any order ?


Answer:   

The 2.4 spec can be in any order.

posted on 2006-05-22 13:02 SmileFace 阅读(1776) 评论(1)  编辑  收藏

FeedBack:
# re: Tomcat中web.xml语句顺序有讲究。
2007-03-08 16:32 | ehow
你们都去吃屎吧  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航:
 

<2006年5月>
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

常用链接

留言簿(2)

随笔分类

随笔档案

文章档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜