XML must be well-formed issued for web.xml file of a JSP/Servlet project

扶醉桌前 提交于 2020-02-07 03:58:46

问题


Getting the error below from Eclipse. What does it mean "must be well-formed"? Is there a mistake in the xml?

The markup in the document following the root element must be well-formed

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<display-name>...</display-name>
<servlet>     
    <servlet-name>action</servlet-name>  
      <servlet-class>...</servlet-class> 
        <init-param>        
        <param-name>config</param-name> 
        <param-value>/WEB-INF/struts-config.xml</param-value>   
        </init-param>     
       <load-on-startup>1</load-on-startup> 
 </servlet>
 <servlet-mapping>  
          <servlet-name>action</servlet-name> 
          <url-pattern>*.do</url-pattern>
 </servlet-mapping>
</web-app>

回答1:


Basically, what a well-formedness error occurs when your tags are not properly nested/not properly closed. It appears to be the most likely case for you since you already have content in your xml. The characters < > & need to be escaped in XML text.

Upload your file to - http://www.cogsci.ed.ac.uk/~richard/xml-check.html to see the well-formedness errors.

Change your XML to:

        <?xml version="1.0" encoding="UTF-8"?>
        <web-app>
        <display-name>...</display-name>
        <servlet>     
            <servlet-name>action</servlet-name>  
              <servlet-class>...</servlet-class> 
                <init-param>        
                <param-name>config</param-name> 
                <param-value>/WEB-INF/struts-config.xml</param-value>   
                </init-param>     
               <load-on-startup>1</load-on-startup> 
         </servlet>
         <servlet-mapping>  
                  <servlet-name>action</servlet-name> 
                  <url-pattern>*.do</url-pattern>
         </servlet-mapping>
        </web-app>


来源:https://stackoverflow.com/questions/13433534/xml-must-be-well-formed-issued-for-web-xml-file-of-a-jsp-servlet-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!