项目场景:
项目场景:使用SpringMVC中的测试视图返回时,配置mvc过程中遇到的问题问题描述:
//springmvc.xml中配置<mvc:annotation-driven/>提示标签不存在
<?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:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/tool"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tool http://www.springframework.org/schema/tool/spring-tool.xsd">
<context:component-scan base-package="com.itheima"/>
<mvc:defalut-servlet-handler/> ==> 提示不存在标签
<mvc:annotation-driven/> ==> 提示不存在标签
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/"/>
<property name="suffix" value=".jsp"/>
</bean>
</beans>
解决方案:
原因是之前通过IDEA的提示选择了
<mvc:annotation/>
这使得导入了xmlns中的添加了
xmlns:mvc="http://www.springframework.org/schema/tool"
而拥有这条之后会将
<mvc:defalut-servlet-handler/>
<mvc:annotation-driven/>
当成错误的标签,去掉xmlns:mvc="http://www.springframework.org/schema/tool"
重新输入即可!!