spring+springMVC+mybatis+shiro -- spring-mvc.xml
<?xml version="1.0" encoding="UTF-8"?> <!-- @author ForeignStudent @version 2017/9/20 --> <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/mvc" xmlns:aop="http://www.springframework.org/schema/aop" 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.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <context:component-scan base-package="com.conferencerooms.controller" /> <!-- spring-mvc jsp视图解析器 --> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> <property name="prefix" value="/WEB-INF/view/" /> <property name="suffix" value=".jsp" /> <property name="order" value="1" /> </bean> <!-- 默认访问跳转到登录页面(即定义无需Controller的url<->view直接映射) --> <mvc:view-controller path="/" view-name="forward:/login.jsp" /> <!-- 这里开启注解 --> <mvc:annotation-driven /> <!-- 扫描静态文件 --> <mvc:resources mapping="/static/**" location="/static/" /> <!-- 文件上传 --> <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <property name="defaultEncoding" value="utf-8" /> <!--1024*200即200k--> <!-- 1024*1024即1M --> <property name="maxUploadSize" value="1048576" /> <!-- <property name="maxInMemorySize" value="40960" /> --> </bean> </beans>
这里扫描controller,配置 jsp 视图,定义默认的项目访问路径,但是这里没有起作用,因为在web.xml里面配置了欢迎页面,我能想到的就是这个原因,web.xml里面的欢迎页面配置去掉后这里才起作用,具体其他原因就不清楚了,希望大神可以给出正确的思路。文件上传在这里是必须要配置的,否则controller接收不到页面传递的文件。