Bogus Eclipse warning for web.xml: “No grammar constraints (DTD or XML schema) detected for the document.”

前端 未结 6 959
忘了有多久
忘了有多久 2020-12-29 02:47

The top of my web.xml file looks like this:




        
6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-29 02:57

    If you have the same (missleading) error message because your XML Editor was not finding the XSD file, you can add a catalog entry.

    You pick the URL specified for the schema, for a declaration like

    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
                          http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"
    

    The URL of the schema file (http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd) is specified for the namespace http://java.sun.com/xml/ns/j2ee. You can now redirect the location of the file with the workspace catalog in Eclipse:

    Preferences -> XML -> XML Catalog -> Add..
    

    Use

    Key Type = Schema Location
    Key = http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd
    

    And then you can use the file chooser to pick actually a XSD file on the filesystem or the workspace.

提交回复
热议问题