错误:根元素后面的文档中的标记必须格式正确

Suh*_*pta 0 java tomcat meta-inf java-ee context.xml

以下是我项目目录中的context.xml文件META-INF:

<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/poll"/>

<Resource name="jdbc/PollDatasource" auth="Container" type="javax.sql.DataSource"
 driverClassName="org.apache.derby.jdbc.ClientDriver"
 url="jdbc:derby://localhost:1527/poll database;create=true"
 username="suhail" password="suhail"
 maxActive="20" maxIdle="10" maxWait="-1" />
Run Code Online (Sandbox Code Playgroud)

但是当我尝试部署/运行项目时,netbeans会产生以下错误:

[Fatal Error] :4:2: The markup in the document following the root element must be 
well-formed.
W:\UnderTest\NetbeansCurrent\poll\nbproject\build-impl.xml:721: Deployment error: 
Tomcat configuration file 
W:\UnderTest\NetbeansCurrent\poll\web\META-INF\context.xml seems to be broken.
Please make sure it is parseable and valid.
See the server log for details.
Run Code Online (Sandbox Code Playgroud)

为什么我会收到此错误?我在中添加了数据库信息context.xml.

在此输入图像描述

小智 6

在context.xml中,取出Context标签中>之前的/右边,并在Resource之后添加结束标记.您的资源应您的上下文中定义.

<Context antiJARLocking="true" path="/poll" >

    <Resource name="jdbc/PollDatasource" auth="Container" type="javax.sql.DataSource"
     driverClassName="org.apache.derby.jdbc.ClientDriver"
     url="jdbc:derby://localhost:1527/poll database;create=true"
     username="suhail" password="suhail"
     maxActive="20" maxIdle="10" maxWait="-1" />

</Context>
Run Code Online (Sandbox Code Playgroud)

希望这可以帮助!