<?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:mvc="http://www.springframework.org/schema/mvc"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
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.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
">
<mvc:resources mapping="/statics/**" location="/statics/"/>
<import resource="application-context.xml"/> <!--引入另一篇配置文件-->
<!--完成请求与处理器之间的映射,并处理JSON数据格式的转码-->
<mvc:annotation-driven>
<mvc:message-converters>
<!--处理时间格式-->
<bean class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/html;charset=UTF-8</value>
<value>application/json;charset=UTF-8</value>
</list>
</property>
<property name="features">
<list>
<value>WriteDateUseDateFormat</value>
</list>
</property>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
<!-- ——————————————— html 和 jsp 共存视图解析器,配置优先级 ——————————————— BEGIN -->
<!-- JSP 视图解析器 -->
<bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/jsp/"/>
<property name="suffix" value=".jsp"/>
<property name="order" value="2"/>
</bean>
<!-- html视图解析器 -->
<!-- 必须先配置freemarkerConfig,注意html是没有prefix前缀属性的 -->
<bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="templateLoaderPath">
<value>/html/</value>
</property>
</bean>
<bean id="htmlviewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
<property name="suffix" value=".html"/>
<property name="order" value="0"/>
<property name="contentType" value="text/html;charset=UTF-8"/>
</bean>
<!--配置拦截器-->
<mvc:interceptors>
<!--拦截所有路径,验证用户是否处于登录状态-->
<mvc:interceptor>
<!--拦截所有html页面-->
<mvc:mapping path="/*"/>
<!--登录页面不进行拦截-->
<mvc:exclude-mapping path="/login.html" />
<mvc:exclude-mapping path="/info/login.do" />
<bean class="com.lianqiao.dache.interceptor.LoginInterceptor" />
</mvc:interceptor>
</mvc:interceptors>
<!--配置MultipartResolver,上传文件-->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="5000000"/>
<property name="defaultEncoding" value="UTF-8"/>
</bean>
</beans>
SSM项目——application-servlet存档
猜你喜欢
转载自blog.csdn.net/wzy18210825916/article/details/89353110
今日推荐
周排行