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接收不到頁面傳遞的文件。web

相關文章
相關標籤/搜索