---
# System prepended metadata

title: '建立web.xml出現Element ''web-app'' cannot have character [children], because the type''s content type is element-only.'
tags: [Java Web-問題以及解決]

---

# 建立web.xml出現Element 'web-app' cannot have character [children], because the type's content type is element-only.

###### tags: `Java Web-問題以及解決`

原程式碼
```xml=
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
         version="4.0">
    <servlet>
        <servlet-name>Demo01Servlet</servlet-name>
        <servlet-class>com.atguigu.servlets.Demo01Servlet</servlet-class>
    </servlet>

    <servlet>
        <servlet-name>Demo02Servlet</servlet-name>
        <servlet-class>com.atguigu.servlets.Demo02Servlet</servlet-class>

    </servlet>>
    <servlet-mapping>
        <servlet-name>Demo01Servlet</servlet-name>
        <url-pattern>/demo01</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>Demo02Servlet</servlet-name>
        <url-pattern>/demo02</url-pattern>
    </servlet-mapping>>

</web-app>
```

原因：
第15行多打一個>