<?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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-4.3.xsd
">
<!-- 启动扫描的controller,多个包可用','隔开, 扫描包下面的子包,可用.* -->
<!-- Spring容器优先加载由ServletContextListener(对应applicationContext.xml)产生的父容器,而SpringMVC(对应mvc_dispatcher_servlet.xml)产生的是子容器。子容器Controller进行扫描装配时装配的@Service注解的实例是没有经过事务加强处理,即没有事务处理能力的Service,而父容器进行初始化的Service是保证事务的增强处理能力的。如果不在子容器中将Service exclude掉,此时得到的将是原样的无事务处理能力的Service,因为在多上下文的情况下,如果同一个bean被定义两次,后面一个优先。 -->
<context:component-scan base-package="com.med.web.controller, com.hpe.web.*,com.hpe.web.dao.impl,com.hpe.web.controller,com.hpe.web.service, com.hpe.task">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service" />
</context:component-scan>
<!-- 启用spring mvc 注解 -->
<context:annotation-config />
<task:executor id="executor" pool-size="5" />
<task:scheduler id="scheduler" pool-size="10" />
<!-- 开启这个配置,识别@Scheduled注解 -->
<task:annotation-driven executor="executor" scheduler="scheduler" />
<!-- 主要作用于@Controller,激活该模式
下面是一种简写形式,完全可以手动配置替代这种简写形式;
它会自动注册 DefaultAnnotationHandlerMapping 与 AnnotationMethodHandlerAdapter 两个bean, 完成请求和注解POJO的映射
是spring MVC为@Controllers分发请求所必须的 -->
<mvc:annotation-driven/>
<!-- jsp页面解析器,当Controller返回XXX字符串时,先通过拦截器,然后该类就会在/WEB-INF/views/目录下,查找XXX.jsp文件-->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/view/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
<!-- don't handle the static resource 将静态资源的处理经由Spring MVC框架交回Web应用服务器处理。而<mvc:resources />更进一步,由Spring MVC框架自己处理静态资源,并添加一些有用的附加值功能。 -->
<!-- <mvc:default-servlet-handler /> -->
<!-- SpringMVC上传文件专用 -->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver" >
<property name="maxUploadSize" value="3221225472"></property>
<property name="maxInMemorySize" value="4096"></property>
</bean>
<!-- 全局配置
<mvc:interceptors>
<bean class="com.capinfo.common.interceptor.PermissionInterceptor"></bean>
</mvc:interceptors>
-->
<!--
配置/WEB-INF/views/目录里面的jsp文件不被DispatcherServlet处理,可以直接通过浏览器访问。
view-name - /WEB-INF/views/里面的jsp文件名(不许后缀即可)
path - 访问地址
<mvc:view-controller path="/header" view-name="header"/> -->
<!-- 用于持有ApplicationContext,可以使用SpringContextHolder.getBean('xxxx')的静态方法得到spring bean对象
<bean class="com.capinfo.common.SpringContextHolder" lazy-init="false" />
-->
<!-- 对静态资源文件的访问 方案一 (二选一)
<mvc:default-servlet-handler/>
-->
<!-- 对静态资源文件的访问 方案二 (二选一)
<mvc:resources mapping="/images/**" location="/images/" cache-period="31556926"/>
<mvc:resources mapping="/js/**" location="/js/" cache-period="31556926"/>
<mvc:resources mapping="/css/**" location="/css/" cache-period="31556926"/> -->
<!-- 全局异常处理 -->
<bean id="exceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<!-- 异常提示页面
<property name="exceptionMappings">
<props>
<prop key="com.capinfo.user.exception.LoginException">loginError</prop>
</props>
</property> -->
<property name="defaultErrorView">
<value>error</value>
</property>
<property name="defaultStatusCode">
<value>500</value>
</property>
<property name="warnLogCategory">
<value>org.springframework.web.servlet.handler.SimpleMappingExceptionResolver</value>
</property>
</bean>
</beans>
1
2
|