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:context="http://www.springframework.org/schema/context"
       xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
       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/context http://www.springframework.org/schema/context/spring-context-4.3.xsd http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd">
    <!--此配置文件为中央控制器配置文件-->
    <!--组件扫描-->
    <context:component-scan base-package="cn.***.***.controller"></context:component-scan>
    <!--导入配置文件-->
    <import resource="classpath:spring/spring-*.xml"></import>
    <!--添加注册驱动,解释方法中的注解(@RequestMapping("/hello"))-->
    <!--通俗的说就是找到对应的方法-->
    <mvc:annotation-driven></mvc:annotation-driven>
    <!--解决路径覆盖问题-->
    <mvc:default-servlet-handler></mvc:default-servlet-handler>


	<!--两个视图解析器看情况使用-->
    <!--视图解析器  给字符串添加前缀和后缀-->
    <!--转向和重定向都不能使用视图解析器-->
     <!--给jsp页面使用的视图解析器-->
    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/view/"></property>
        <property name="suffix" value=".jsp"></property>
    </bean>
    
    <!--freemarker视图解析器-->
	<!-- 注册 FreeMarker 配置类 -->
	<bean class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
		<!-- 配置 FreeMarker 的文件编码 -->
		<property name="defaultEncoding" value="UTF-8" />
		<!-- 配置 FreeMarker 寻找模板的路径 -->
		<property name="templateLoaderPath" value="/WEB-INF/views/"/>
	</bean>
	<!-- 注册 FreeMarker 视图解析器 -->
	<bean class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
		<!-- 是否在 model 自动把 session 中的 attribute 导入进去 -->
		<property name="exposeSessionAttributes" value="true" />
		<!-- 配置逻辑视图自动添加的后缀名 -->
		<property name="suffix" value=".ftl" />
		<!-- 配置响应头中 Content-Type 的指 -->
		<property name="contentType" value="text/html;charset=UTF-8" />
	</bean>
	
    <!--解析文件上传-->
    <!--将前端上传的文件解析到MultipartFile中-->
    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <property name="maxUploadSize" value="10240000"></property>
        <property name="defaultEncoding" value="UTF-8"></property>
    </bean>

	<!-- 配置拦截器,两个拦截器的顺序不能乱 -->
  <mvc:interceptors>
		<mvc:interceptor>
			<mvc:mapping path="/**"/>
			<mvc:exclude-mapping path="/login.do"/>
			<mvc:exclude-mapping path="/logout.do"/>
			<bean class="cn.wolfcode.rbac.interceptor.VerifUserInterceptor"></bean>
		</mvc:interceptor>
	   <mvc:interceptor>
		   <mvc:mapping path="/**"/>
		   <mvc:exclude-mapping path="/login.do"/>
		   <mvc:exclude-mapping path="/logout.do"/>
		   <bean class="cn.wolfcode.rbac.interceptor.VerifPermissionInterceptor"></bean>
	   </mvc:interceptor>
	</mvc:interceptors>

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值