dispatcher-servlet.xml 5.34 KB
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:oxm="http://www.springframework.org/schema/oxm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans   
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd  
http://www.springframework.org/schema/oxm
http://www.springframework.org/schema/oxm/spring-oxm-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">

	<!-- 开启controller注解支持 -->
	<context:component-scan base-package="com.bjivt.showtime.api.controller">
		<context:include-filter type="annotation"
			expression="org.springframework.stereotype.Controller" />
	</context:component-scan>

	<mvc:annotation-driven
		content-negotiation-manager="contentManager">
		<mvc:message-converters>
			<ref bean="fastJsonConverter" />
			<ref bean="xstreamConverter" />
		</mvc:message-converters>
	</mvc:annotation-driven>
	
	<!-- 配置拦截器 -->
	<!-- mvc:interceptors>
		<bean class="com.bjivt.api.interceptor.SpringMVCInterceptor"/>
	</mvc:interceptors-->
	<mvc:interceptors>
	    <mvc:interceptor>
	        <mvc:mapping path="/**"/>
			<bean class="com.bjivt.showtime.api.interceptor.LogInterceptor">
			</bean>
		</mvc:interceptor>
	    <mvc:interceptor>
	        <mvc:mapping path="/**"/>
			<bean class="com.bjivt.showtime.api.interceptor.BaseInterceptor">
			<property name="excludeUrls">
				<list>
					<value>/user/sendsms.json</value>
					<value>/user/login.json</value>
					<value>/user/thridpartLogin.json</value>
					<value>/requestAppInfo.json</value>
					<value>/getAdvertisement.json</value>
					<value>/getLoopBannerList.json</value>
					<value>/live/share.json</value>
					<value>/shareLive</value>
					<value>/user/boundingThirdPartAccount.json</value>
					<value>/user/userRechargeLog.json</value>
				</list>
			</property>
			</bean>
		</mvc:interceptor>
	</mvc:interceptors>

	<!-- <mvc:default-servlet-handler/> -->
	<mvc:resources mapping="css/**" location="/css/" />
	<mvc:resources mapping="js/**" location="/js/" />
	<mvc:resources mapping="images/**" location="/images/" />
	<mvc:resources mapping="upload/**" location="/upload/" />
	<mvc:resources mapping="html/**" location="/html/" />
	<mvc:resources mapping="assets/**" location="/assets/" />
	<mvc:resources mapping="img/**" location="/img/" />

	<bean id="contentManager"
		class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
		<property name="favorPathExtension" value="true" />
		<property name="ignoreAcceptHeader" value="true" />
		<property name="defaultContentType" value="application/json" />
		<property name="mediaTypes">
			<map>
				<entry key="json" value="application/json" />
				<entry key="xml" value="application/xml" />
				<entry key="html" value="text/html" />
			</map>
		</property>
	</bean>

	<bean id="xmlMarshaller" class="org.springframework.oxm.xstream.XStreamMarshaller">
		<property name="streamDriver">
			<bean class="com.thoughtworks.xstream.io.xml.StaxDriver" />
		</property>
		<property name="autodetectAnnotations" value="true" />
	</bean>

	<bean id="xstreamConverter"
		class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter">
		<property name="marshaller" ref="xmlMarshaller" />
		<property name="unmarshaller" ref="xmlMarshaller" />
		<property name="supportedMediaTypes" value="application/xml" />
	</bean>

	<bean id="fastJsonConverter"
		class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">
		<property name="supportedMediaTypes" value="application/json" />
	</bean>

	<bean id="jspViewResolver"
		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix" value="/" />
		<property name="suffix" value=".jsp" />
	</bean>
	<!-- 定时器  这个是定时器要调用方法的类 --> 
    <bean id="SpringQtzJob" class="com.bjivt.showtime.api.job.LiveHeartbeatJob"/>  
	<!--
	 <bean id="SpringQtzJobMethod" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">  
	    <property name="targetObject">  
	        <ref bean="SpringQtzJob"/>  
	    </property>  
	    <property name="targetMethod">  要执行的方法名称  
	        <value>doit</value>  
	    </property>  
	</bean>  
    <bean id="cronTrigger"  
        class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">  
        <property name="jobDetail" ref="SpringQtzJobMethod" />  
        <property name="cronExpression" value="*/5 * * * * ?" />  
  
    </bean>  
    <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean"  
        autowire="no">  
        <property name="triggers">  
            <list>  
                <ref bean="cronTrigger" />  
            </list>  
        </property>  
    </bean> 
    --> 
	<bean id="multipartResolver"
		class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
		<!-- 设置上传文件的最大尺寸为1MB -->
		<property name="maxUploadSize">
			<value>70048576</value>
		</property>
		<property name="uploadTempDir">
			<value>upload/temp</value>
		</property>
	</bean>

</beans>