2

When Eclipse detects an invalid XML document, in my case a web.xml file, it dumps the content model of the DTD and tells me that the element is invalid. This is quite unhelpful, since it ends up telling me that:

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

In a 900-line web.xml file, the error is not easy to find.

How can I single out the first element which causes the document to be invalid?

4

2 に答える 2

2

これは古い質問ですが、私にとってはweb.xmlオプションの順序になりました。エラーメッセージを見る場合、要素はエラーにリストされている正確な順序である必要があります。例えば:

<web-app>

<display-name>LBSPing!</display-name>

<context-param>
    ...
</context-param>

<listener>
    ...
</listener>

<servlet>
    ...
</servlet>

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

</web-app>

私の場合、コンテキストパラメータはサーブレットノードとリスナーノードの後に​​あり、これが問題の原因でした。

于 2012-08-13T13:38:16.370 に答える
2

web.xml のコピーを作成し、要素が見つかるまでコンテンツを半分にカットします (整形式のままであることを確認します)。その後、コピーしたファイルの残りの部分を追加します。

于 2010-08-09T07:45:46.990 に答える