在SpringMVC中启用aop,springmvc.xml配置方法

<?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:p="http://www.springframework.org/schema/p"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
        xmlns:aop="http://www.springframework.org/schema/aop"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
	http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">

	<!-- 注解驱动 -->
	<mvc:annotation-driven />

	<!--要扫描的Controller的package -->
	<context:component-scan base-package="cn.ffcs.iot.controller" /> 
	<!-- 定义视图解析器 -->
	<bean
		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix" value="/WEB-INF/views/" />
		<property name="suffix" value=".jsp" />
	</bean>

	<!-- 启动@aspectj的自动代理支持-->
	<aop:aspectj-autoproxy />
</beans>

1.添加属性xmlns:aop
2.为xsi:schemaLocation的值添加两个新的xsd
3.添加标签<aop:aspectj-autoproxy />

posted @ 2020-12-11 15:10  灌汤非  阅读(377)  评论(0)    收藏  举报