在写java项目,配置web.xml文件的<location>时,出现以下错误:
DescriptionResourcePathLocationType cvc-complex-type.2.4.a: Invalid content was found starting with element 'location'.
百思不得其解,只好百度,终于解决了,但是还是不知道其原理,这里这是奉上解决方法。如果有大神知道原理,还望告知,非常感谢!
解决办法:将“http://www.springmodules.org/schema/cache/springmodules-cache.xsd http://www.springmodules.org/schema/cache/springmodules-ehcache.xsd”这段话加入到xml文件的"xmlns:xsi="的属性中,即可解决(示例如下)
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
http://www.springmodules.org/schema/cache/springmodules-cache.xsd
http://www.springmodules.org/schema/cache/springmodules-ehcache.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<display-name></display-name>