springmvc.xml配置如下
<?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.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<!-- 配置推荐使用注解驱动,会默认的加载上面的两个 HandlerMapping, HandlerAdapter -->
<mvc:annotation-driven />
<!-- 开启springmvc注解扫描 -->
<context:component-scan base-package="cn.usermanage.controller"></context:component-scan>
<!-- 这个是excelView的加载,原生态ssm不需要,所以这里是可以省略的 -->
<!-- <bean name="excelView" class="cn.usermanage.view.UserExcelView"></bean> -->
<!-- 视图解析器 -->
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- 前缀,这里是请求的路径文件 -->
<property name="prefix" value="/WEB-INF/views/"></property>
<!-- 后缀 ,支持.jsp的请求-->
<property name="suffix" value=".jsp"></property>
</bean>
<!-- 以上是原生态的ssm配置 -->
<!-- 配置第二个视图解析器 -->
<!-- <bean class="org.springframework.web.servlet.view.BeanNameViewResolver">
<property name="order" value="1"></property>
</bean> -->
<!-- 定义文件上传解析器 -->
<!-- <bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
设定默认编码
<property name="defaultEncoding" value="UTF-8"></property>
设定文件上传的最大值5MB,5*1024*1024
<property name="maxUploadSize" value="5242880"></property>
</bean> -->
<!-- 解决静态资源被拦截的问题 -->
<!-- <mvc:default-servlet-handler/> -->
</beans>
原文链接:https://blog.csdn.net/qq_30764991/article/details/79816261