All Downloads are FREE. Search and download functionalities are using the official Maven repository.

conf.spring-mvc.xml Maven / Gradle / Ivy

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-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/aop
      http://www.springframework.org/schema/aop/spring-aop.xsd">
    
    
    <!-- 激活组件扫描功能,在包cn.basics.aop及其子包下面自动扫描通过注解配置的组件 -->
	<context:component-scan base-package="cn.basics.aop"/>
	<!-- 激活自动代理功能 -->
	<aop:aspectj-autoproxy proxy-target-class="true"/>
	
    <!-- 登录、权限验证拦截器 begin -->
    <mvc:interceptors>
		<mvc:interceptor>
			<mvc:mapping path="/**" />
			<bean class="cn.basics.authority.interceptor.AuthorityAnnotationInterceptor"></bean>
		</mvc:interceptor>
	</mvc:interceptors>
	<!-- 登录、权限验证拦截器 end -->
	<!-- 登录、权限验证实现 begin -->
	<bean id="myBaseServiceImpl" class="cn.basics.service.impl.MyBaseServiceImpl" />
	<bean id="roleServiceImpl" class="cn.basics.service.impl.RoleServiceImpl" />
	<bean id="authorityInterface" class="cn.basics.interfaces.AuthorityInterfaceImpl">
		<property name="roleService" ref="roleServiceImpl"></property>
	</bean>
	<bean id="authorityAnnotationInterceptor" class="cn.basics.authority.interceptor.AuthorityAnnotationInterceptor" >
		<property name="defaultAuthorityInterface" ref="authorityInterface"></property>
		<property name="myBaseService" ref="myBaseServiceImpl"></property>
	</bean>
	<!-- 登录、权限验证实现 end -->

	<!-- 解决SpringMvc拦截*.html @ResponseBody注解直接返回对象并转换成JSON时出现406问题,同时解决了返回String类型乱码的问题 -->
	<mvc:annotation-driven content-negotiation-manager="contentNegotiationManager" />
	<bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
		<property name="favorPathExtension" value="false" />
		<property name="favorParameter" value="false" />
		<property name="ignoreAcceptHeader" value="false" />
		<property name="mediaTypes">
			<value>
				atom=application/atom+xml
				html=application/json
				json=application/json
				*=*/*
			</value>
		</property>
	</bean>

	<!-- 扫描controller(controller层注入) -->
	<context:component-scan base-package="cn.basics.controller" />
	<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"></bean>

	<!-- 对模型视图添加前后缀 -->
	<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="suffix" value=".jsp" />
		<!-- <property name="prefix" value="/WEB-INF/web/" /> -->
		<property name="prefix" value="/web/" />
	</bean>
	<!-- 静态资源访问 ue for oss 使用 -->
	<mvc:resources mapping="/common/**" location="/common/" />

	<!-- 配置Druid和Spring关联监控配置 begin -->
	<!-- 方法名正则匹配拦截配置 -->
	<!-- 开启spring方法调用监控 -->
    <bean id="druid-stat-interceptor" class="com.alibaba.druid.support.spring.stat.DruidStatInterceptor"></bean>
    <bean id="druid-stat-pointcut" class="org.springframework.aop.support.JdkRegexpMethodPointcut" scope="prototype">
       <property name="patterns">
           <list>
               <value>cn.basics.*</value>
               <value>cn.basics.*.*</value>
               <value>cn.basics.*.*.*</value>
           </list>
       </property>
    </bean>
	<aop:config proxy-target-class="true">
		<aop:advisor advice-ref="druid-stat-interceptor" pointcut-ref="druid-stat-pointcut" />
	</aop:config>
	<!-- 配置Druid和Spring关联监控配置 end -->
</beans>




© 2015 - 2025 Weber Informatics LLC | Privacy Policy