springmvc配置

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-3.2.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx-3.2.xsd ">
    
    <!-- 开启注解 -->
    <mvc:annotation-driven></mvc:annotation-driven>
    <!-- 解析静态文件 -->
    <mvc:default-servlet-handler />    
    <mvc:resources location="/admin/" mapping="/admin/**" />
    <mvc:resources location="/business/" mapping="/business/**" />
    <mvc:resources location="/css/" mapping="/css/**" />
    <mvc:resources location="/data/" mapping="/data/**" />
    <mvc:resources location="/dls/" mapping="/dls/**" />
    <mvc:resources location="/images/" mapping="/images/**" />
    <mvc:resources location="/js/" mapping="/js/**" />
    <mvc:resources location="/lib/" mapping="/lib/**" />
    <mvc:resources location="/news/" mapping="/news/**" />
    <mvc:resources location="/pages/" mapping="/pages/**" />
    <mvc:resources location="/*.html" mapping="/*.html" />
     
    <!-- 文件上传 设置上传最大尺寸,默认编码-->
    <bean id="multipartResolver"
        class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <property name="maxUploadSize">
            <value>5242880</value>
        </property>
        <property name="defaultEncoding">
            <value>UTF-8</value>
        </property>
    </bean>
    
    <!--  避免返回为json类型出现下载的状况  -->    
    <bean id="mappingJacksonHttpMessageConverter"
        class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
        <property name="supportedMediaTypes">
            <list>
                <value>text/html;charset=UTF-8</value>
            </list>
        </property>
    </bean>
    
    <mvc:interceptors>    
    
        <!-- 管理员登陆拦截器 不包含某些路径,这里的 exclude 并不仅限于url,也可以是一个请求-->
        <mvc:interceptor>
            <mvc:mapping path="/post/admin/**"/>
            <mvc:exclude-mapping path="/post/admin/login"/>
            <mvc:exclude-mapping path="/post/admin/getSession"/>
            <bean class="com..interceptor.AdminSessionCheckInterceptor"/>
        </mvc:interceptor>
        <!-- 用户拦截器 -->
        <mvc:interceptor>    
            <mvc:mapping path="/post/**"/>
            <mvc:exclude-mapping path="/post/admin/**"/>
            <!-- <mvc:exclude-mapping path="/business/regInfo.html"/> -->
            <mvc:exclude-mapping path="/post/memberLogin"/>        <!-- 用户登录 -->
            <mvc:exclude-mapping path="/post/getMemberSession"/><!-- 获取session -->
            <mvc:exclude-mapping path="/post/checkMember"/>        <!-- 检查用户名是否存在 -->
            <mvc:exclude-mapping path="/business/regInfo.html"/><!-- 用户注册页面 -->
            <mvc:exclude-mapping path="/post/regist"/>            <!-- 用户注册请求 -->
            <mvc:exclude-mapping path="/post/uploadPic"/>
            <mvc:exclude-mapping path="/post/uploadTagExcelFile"/>
            <mvc:exclude-mapping path="/post/processUpload"/>    <!-- 不拦截 上传图片 -->
            <bean class="com.interceptor.MemberSessionCheckInterceptor"/><!--这里是进行session检查-->
        </mvc:interceptor>    
        
    </mvc:interceptors>
        
    <!-- 全局异常 需要实现 HandlerExceptionResolver 接口-->
    <bean class="com.exception.CommonsExceptionResolve" lazy-init="false"/>
    
    <!-- 视图解析器 -->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" >
        <!-- 返回路径前缀 -->
        <property name="prefix" value="/"/>
        <!-- 返回路径后缀 可以是jsp注意前面有  "." -->
        <property name="suffix" value=".html"/>
    </bean>
    
</beans>


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值