开发者

web app web.xml error [duplicate]

This question already has answers here: Getting error: The content of element type "web-app" must match, (3 answers) Closed 5 years ago.

I am getting an error in my GWT application being developed in Eclipse. It's in the web.xml file. Here's the error:

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*)".

I have seen numerous posts about this and the problem is the order of the elements of the file, but that fix doesn't work for me (I have also tried putting all the <servlet-mapping> tags right after the corresponding <servlet>, it did not work either)

My web.xml file :

<?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>

  <servlet>
    <servlet-name>dispatch</servlet-name>
    <servlet-class>com.yachtcloser.server.DispatchServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet>
    <servlet-name>upload</servlet-name>
    <servlet-class>com.yachtcloser.server.UploadServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet> 

  <servlet>
    <servlet-name>download</servlet-name>
    <servlet-class>com.yachtcloser.server.DownloadServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet>
    <servlet-name>login</servlet-name>
    <servlet-class>com.yachtcloser.server.LoginServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet-mapping>
    <servlet-name>dispatch</servlet-name>
    <url-pattern>/dispatch.do</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>upload</servlet-name>
    <url-pattern>/upload.do</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet开发者_如何转开发-name>download</servlet-name>
    <url-pattern>/download.do</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>login</servlet-name>
    <url-pattern>/login.do</url-pattern>
  </servlet-mapping>

  <!-- Default page to serve -->
  <welcome-file-list>
    <welcome-file>Yc.html</welcome-file>
  </welcome-file-list>

</web-app>

Are there any other ways of tracking this error; other files that are linked to this?


well, as per new format of DTD web-app tag might contains following tags. <!ELEMENT web-app (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*)>

above mentioned icon, display-name, description, distributable....etc are in the same order as they have mentioned in the DTD file.

e.g. if you put description tag before display-name it gives error.


I deleted the file and pasted the text from the old one into a new file with the same name and now there's no errors.


Just for a reference: A SelectAll->Cut->Save->Paste->Save also fixes the problem. Probably there is a line ending character issue.


I followed the suggestion for "copy all" - "cut" - "paste" - "save" and this seemed to clear up the message. I found that in the "pasted" version all tabs had been converted to spaces.

So it seems that the web.xml validator in Eclipse does not like tabs.


The error itself gives you the clue. The order of the elements in your web.xml should follow the order specified in the error.

<displayname>
</displayname>
<description>
</description>

....... like this the elements should be in order as it says in the error.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜