代码改变世界

springmvc.xml文件的基本配置

2020-05-12 11:30  躲躲藏藏  阅读(179)  评论(0)    收藏  举报

<?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:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.2.xsd">

###当遇到这些注解时就会自动加载###

<!-- 只需要扫描包中的 Controller 注解 -->
<context:component-scan base-package="com.drommanagement.programmer.controller">
<context:include-filter type="annotation"
expression="org.springframework.stereotype.Controller" />
</context:component-scan>

<!-- 启动 mvc 注解驱动 ,不启动会不扫描注解-->
<mvc:annotation-driven></mvc:annotation-driven>

<!-- 启动定时任务 -->
<task:annotation-driven/>

<!-- 静态资源处理 -->
<mvc:default-servlet-handler/>

<!-- 配置视图解析器 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/"></property><!-- 视图前缀 -->
<property name="suffix" value=".jsp"></property><!-- 视图后缀 -->
</bean>


<!-- 后台访问拦截器 -->

<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/**"/>
<mvc:exclude-mapping path="/system/login"/>
<mvc:exclude-mapping path="/system/get_cpacha"/>
<mvc:exclude-mapping path="/h-ui/**"/>
<mvc:exclude-mapping path="/easyui/**"/>
<mvc:exclude-mapping path="/home-resources/**"/>
<mvc:exclude-mapping path="/home/**"/>
<bean class="com.drommanagement.programmer.interceptor.LoginInterceptor"></bean>
</mvc:interceptor>
</mvc:interceptors>
</beans>