spring-web-context.xml 2.9 KB
<?xml  version="1.0" encoding="UTF-8"?>
<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="http://www.springframework.org/schema/beans"
	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/aop
                        http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
                        http://www.springframework.org/schema/mvc
                        http://www.springframework.org/schema/mvc/spring-mvc.xsd">

	<context:property-placeholder location="classpath:*.properties" />
	<context:component-scan base-package="com.ui" />
    <!-- 打开aop 注解 -->
    <aop:aspectj-autoproxy proxy-target-class="true"/>

	<mvc:annotation-driven>
		<mvc:message-converters>
			<ref bean="stringConverter" />
			<ref bean="jsonConverter" />
		</mvc:message-converters>
	</mvc:annotation-driven>
	
	<!--字符串转换器 -->
	<bean id="stringConverter" class="org.springframework.http.converter.StringHttpMessageConverter">
		<property name="supportedMediaTypes">
			<list>
				<value>text/plain;charset=UTF-8</value>
				<value>text/html;charset=UTF-8</value>
			</list>
		</property>
	</bean>
	
	<!-- json转换器 application/json -->
	<bean id="jsonConverter" class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">
	</bean>

	<bean
		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix">
			<value>/jsp/</value>
		</property>
		<property name="suffix">
			<value>.jsp</value>
		</property>
	</bean>

	<!-- 静态资源访问  -->
	<mvc:resources location="/js/" mapping="/js/**"/>
	<mvc:resources location="/css/" mapping="/css/**"/>
	<mvc:resources location="/img/" mapping="/img/**"/>
	<mvc:resources location="/jsp/" mapping="/jsp/**"/>
	<mvc:resources location="/fonts/" mapping="/fonts/**"/>
	<mvc:resources location="/script/" mapping="/script/**"/>

	<!--<mvc:interceptors>-->
		<!--&lt;!&ndash; 登录验证 &ndash;&gt;-->
		<!--<mvc:interceptor>-->
			<!--<mvc:mapping path="/**"/>-->
			<!--<mvc:exclude-mapping path="/hystrix/**"/>-->
			<!--<mvc:exclude-mapping path="/user/**"/>-->
			<!--<mvc:exclude-mapping path="/img/**"/>-->
			<!--<mvc:exclude-mapping path="/css/**"/>-->
			<!--<mvc:exclude-mapping path="/js/**"/>-->
			<!--<mvc:exclude-mapping path="/fonts/**"/>-->
			<!--<mvc:exclude-mapping path="/script/**"/>-->
			<!--<bean class="com.ui.interceptor.AuthInterceptor"/>-->
		<!--</mvc:interceptor>-->
	<!--</mvc:interceptors>-->

</beans>