zoukankan      html  css  js  c++  java
  • 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接收不到页面传递的文件。

  • 相关阅读:
    遇到shell重定向的一个奇怪问题:'消失'的标准输入!
    步步深入:MySQL架构总览->查询执行流程->SQL解析顺序
    [来自妹纸的挑战]-展开/还原多层链表
    【Shell】Linux 一行 多命令
    【Shell】通配符与特殊符号
    【Shell】变量的取用、删除、取代与替换
    【LeetCode】Find Minimum in Rotated Sorted Array 在旋转数组中找最小数
    【LeetCode】Maximum Product Subarray 求连续子数组使其乘积最大
    【LeetCode】Reverse Words in a String 反转字符串中的单词
    【面试题】比给定数大的最小数
  • 原文地址:https://www.cnblogs.com/foreign-student/p/7593992.html
Copyright © 2011-2022 走看看