Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
884 views
in Technique[技术] by (71.8m points)

servlets - Getting error: The content of element type "web-app" must match,

When I build my project in Eclipse Helios Service Release 2, I get an error in my web.xml. Please suggest what I have to do for this. In my project I am using DTD 2.2. The error is below.

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

question from:https://stackoverflow.com/questions/5712906/getting-error-the-content-of-element-type-web-app-must-match

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The error message tells you in detail in what order the elements are supposed to be placed and how many of them are allowed. In other words, the ordering or amount of the elements inside the <web-app> of your web.xml is incorrect. For example, as per the error message, <servlet> needs to go before <servlet-mapping>. The ? suffix means that there may be zero or one of them. The * suffix means that there may be zero or many of them.

So, the example below is invalid:

<servlet>...</servlet>
<servlet-mapping>...</servlet-mapping>

<servlet>...</servlet>
<servlet-mapping>...</servlet-mapping>

<servlet>...</servlet>
<servlet-mapping>...</servlet-mapping>

While the example below is valid:

<servlet>...</servlet>
<servlet>...</servlet>
<servlet>...</servlet>

<servlet-mapping>...</servlet-mapping>
<servlet-mapping>...</servlet-mapping>
<servlet-mapping>...</servlet-mapping>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...