<!-- 啓動Springmvc註解驅動 -->
<mvc:annotation-driven/>
<!-- 返回json 方法一 須要導入 fastjson.jar包 -->
<mvc:annotation-driven>
<mvc:message-converters register-defaults="false">
<!-- 避免IE執行AJAX時,返回JSON出現下載文件 -->
<bean id="fastJsonHttpMessageConverter"class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<!-- 這裏順序不能反,必定先寫text/html,否則ie下出現下載提示 -->
<value>text/html;charset=UTF-8</value>
<value>application/json;charset=UTF-8</value>
</list>
</property>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
<!-- 返回json 方法二 須要導入 jackson-annotations.jar,jackson-core.jar,jackson-databind.jar-->
<!-- <beanclass="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/>
<beanclass="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
<property name="messageConverters">
<list>
<beanclass="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/html; charset=UTF-8</value>
<value>application/json;charset=UTF-8</value>
</list>
</property>
</bean>
<beanclass="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/html; charset=UTF-8</value>
<value>application/json;charset=UTF-8</value>
</list>
</property>
</bean>
</list>
</property>
</bean> -->
<!-- 其下與返回json 無關 -->
<!-- 自動將控制器加載到bean -->
<context:component-scan base-package="org.controller"></context:component-scan>
<!-- 配置處理靜態資源的請求 -->
<mvc:resources location="/resources/"mapping="*/res/**"/>
<!-- 攔截器配置 -->
<mvc:interceptors>
<beanclass="org.aop.LoginInteceptor"/>
</mvc:interceptors>
<!-- 配置視圖解析器 -->
<beanclass="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix"value="/WEB-INF/jsp/"/>
<property name="suffix"value=".jsp"/><!--可爲空,方便實現自已的依據擴展名來選擇視圖解釋類的邏輯 -->
<property name="viewClass"value="org.springframework.web.servlet.view.JstlView"/>
</bean>
<!-- 上傳 須要使用到的配置-->
<bean id="multipartResolver"class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize"value="1046666000"/>
</bean>
<!--配置全局的異常-->
<!-- <bean id="exceptionResolver"class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
<props>
<prop key="com.guanlan.util.SportException">error</prop>
</props>
</property>
</bean> -->