配置自己第一个struts2的时候,在eclipse中创建了一个新的Web Project,web.xml报错如下
cvc-complex-type.2.3: Element 'web-app' cannot have character [children], because the type's content type is element-only.
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
方法一:
后来发现,并不是struts2配置代码有问题,将javaee改为j2ee就好了
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
改为
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
办法二:
由于是粘贴过来的编码可能有问题,将xml中的文本重新手打输入一遍,一般就会解决这种问题。