在SpringMVC中啟用aop,springmvc.xml配置方法
阿新 • • 發佈:2020-12-11
<?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 />