Myeclipse中java web.xml报错cvc-complex-type.2.3: Element 'web-app' cannot have character [children], because the type's content type is element- only.

web.xml文件添加servlet访问限制后出现如下错误:

  cvc-complex-type.2.3: Element 'web-app' cannot have character [children], because the type's content type is element-  only.

翻译:

  cvc-complex-type.2.3:元素'web-app'不能包含character [children],因为该类型的内容类型是仅包含元素的。

错误截图如下:

  

解决办法一:

  出错原因为xml头文件中第三行:
  xmlns="http://java.sun.com/xml/ns/javaee"
  改成javaee改为j2ee后解决问题。

  

 解决办法二:

  由于是粘贴过来的编码可能有问题,将xml中的文本重新手打输入一遍,一般就会解决这种问题。

  

原文地址:https://www.cnblogs.com/chenmingjun/p/9178833.html