使用SpringMVC项目的时候,访问项目的时候出现异常。
真的是绝绝子
解决方案如下:
在springMVC配置文件的时候,加下
<mvc:default-servlet-handler/>
还有注意相关的包要导入项目中
还有还有springMVC.xml的声明要正确
<?xml version="1.0" encoding="UTF-8"?>
<beans 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/mvc
https://www.springframework.org/schema/mvc/spring-mvc.xsd"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans">
<!--配置包扫描器-->
<context:component-scan base-package="com.slyx"/>
<!--springmvc注解-->
<mvc:annotation-driven/>
<!--静态资源放行-->
<mvc:default-servlet-handler/>
</beans>