必须为JSP/Servlet项目的web.xml文件发布格式正确的XML [英] XML must be well-formed issued for web.xml file of a JSP/Servlet project
问题描述
从Eclipse中获取以下错误. 必须格式正确" 是什么意思? xml中有错误吗?
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>
推荐答案
基本上,当标签未正确嵌套/未正确关闭时,会发生格式错误.对于您来说,这似乎是最有可能的情况,因为您已经在xml中包含了内容.字符< >&需要以XML文本转义.
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.
将文件上传到- http://www.cogsci. ed.ac.uk/~richard/xml-check.html 查看格式错误.
Upload your file to - http://www.cogsci.ed.ac.uk/~richard/xml-check.html to see the well-formedness errors.
将XML更改为:
<?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>
这篇关于必须为JSP/Servlet项目的web.xml文件发布格式正确的XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!