在 SpringMVC 的配置文件中,一般会出现这个错误,即通配符的匹配很全面, 但无法找到元素 XXX:XXX 。
出现这样错误的原因一般就是因为xml文件的问题。
如果在头文件中没有引入
xmlns:mvc="http://www.springframework.org/schema/mvc"
在xml中就会直接报错提示你
如果这行代码引入了,还是依旧报这个错,这就说明xsi:schemaLocation 没有写。
如下:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.2.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd">
上下要保证一致才不会报错。
本文详细解析了SpringMVC配置文件中出现通配符匹配全面但找不到元素XXX:XXX错误的原因,并提供了相应的解决方案。重点在于确保XML文件正确引入命名空间及XSI属性设置,避免报错。
853

被折叠的 条评论
为什么被折叠?



