当 Eclipse 检测到无效的 XML 文档(在我的例子中是一个web.xml
文件)时,它会转储 DTD 的内容模型并告诉我该元素无效。这是非常无益的,因为它最终告诉我:
元素类型“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*)”。
在一个 900 行的 web.xml 文件中,错误不容易发现。
如何挑选出导致文档无效的第一个元素?