问题描述:通配符的匹配很全面, 但无法找到元素 'mvc:default-servlet-handler' 的声明。
原因:
虽然在xml文件上方声明了mvc,但没有配置此声明对应的文件信息,正确配置如下:
mvc声明用http://www.springframework.org/schema/mvc/spring-mvc.xsd这个文件来解析,一个声明必须跟着一组类似网址的文件来解析。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
">
<!-- 扫描web包,应用Spring的注解 -->
<context:component-scan base-package="com.htk.web"/>
<!-- 静态资源(js、image等)的访问 -->
<mvc:default-servlet-handler/>
<!-- 开启注解 -->
<mvc:annotation-driven/>
参考:https://blog.csdn.net/hetongun/article/details/77667038