1.使用<aop:config></aop:config>

2.首先我们需要配置<aop:aspect></aop:aspect>,就是配置切面

  2.1首先配置切面的id,也就是切面叫什么名称,我们起名字为id="myLogAspect"

  2.2我们的切面是由哪一个类来做的,ref="logAspect",ref属性值是spring所管理的类(bean)

3.配置pointcut,下面需要配置,我们要在哪一些类里面加入这些操作。或者说在那些类里面加入切面,id=""指明我们是在哪些类中加入,expression

  3.1<aop:pointcut id="logPointCut" expression="execution(* org.zttc.itat.spring.dao.*.add*(..))||

execution(* org.zttc.itat.spring.dao.*.delete*(..))||

execution(* org.zttc.itat.spring.dao.*.update*(..))" />

4.配置before,method=""指明,我们要调用的是切面(切面是ref="logAspect",前面已经配置过了)里面的哪一个方法 ,point-ref=""表明我们要引入哪一个PointCut(id="logPointCut",前面也已经配置过了),也就是说我们的logStart方法会在pointcut中配置的那些类中的那些方法中加入。

  4.1<aop:before method="logStart" point-ref="logPointCut">

  4.2<aop:before method="logEnd" point-ref="logPointCut">

  4.3<aop:before method="logAround" point-ref="logPointCut">

注解和xml哪个方便一些?

  使用注解的时候,我们需要为每一个method(before,after,around)都配置exexution,而使用xml我们只需要配置一次就可以了,从而xml更方便

xml实现AOP的更多相关文章

  1. 基于XML的AOP配置

    创建spring的配置文件并导入约束 此处要导入aop的约束 <?xml version="1.0" encoding="UTF-8"?> < ...

  2. spring的基于xml的AOP配置案例和切入点表达式的一些写法

    <?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.spr ...

  3. Spring中基于xml的AOP

    1.Aop 全程是Aspect Oriented Programming 即面向切面编程,通过预编译方式和运行期动态代理实现程序功能的同一维护的一种技术.Aop是oop的延续,是软件开发中的 一个热点 ...

  4. Spring、XML配置AOP

    新建一个AOP类: public class MyInterceptor2 { public void doAccessCheck(){ System.out.println("前置通知 & ...

  5. Spring 使用xml配置aop

    1.xml文件需要引入aop命名空间 2.xml内容: <?xml version="1.0" encoding="UTF-8"?> <bea ...

  6. Spring初学之xml实现AOP前置通知、后置通知、返回通知、异常通知等

    实现两个整数的加减乘除,在每个方法执行前后打印日志. ArithmeticCalculator.java: package spring.aop.impl.xml; public interface ...

  7. applicationContext.xml配置AOP切面编程

    Computer.java package com.wh.aop2; public class Computer { public void play01(){ System.out.println( ...

  8. 基于 XML 的 AOP 配置(1)

    本文连接:https://www.cnblogs.com/qzhc/p/11969734.html 接下来我将用一个很简单的实例 1. 环境搭建 1.1. 第一步:准备必要的代码 业务层代码: Acc ...

  9. Spring基于XML配置AOP

    目录结构: D:\Java\IdeaProjects\JavaProj\SpringHelloWorld\src\cn\edu\bjut\service\StudentService.java pac ...

随机推荐

  1. Nginx报 No input file specified. 的问题解决之路 转

    https://m.aliyun.com/yunqi/articles/34240 今天接手公司的一个项目,照例将项目clone下来,配置本地host,nginx,然后访问. 怎么回事?迅速在php的 ...

  2. HUST——1106xor的难题之二(异或树状数组单点修改和区间查询)

    1106: xor的难题之二 时间限制: 2 Sec  内存限制: 128 MB 提交: 8  解决: 3 题目描述 上次Alex学长的问题xor难题很简单吧,现在hkhv学长有个问题想问你们. 他现 ...

  3. POJ3071 Football 【概率dp】

    题目 Consider a single-elimination football tournament involving 2n teams, denoted 1, 2, -, 2n. In eac ...

  4. 如何用1个小时了解JSON

    W3school ↑↑↑学这个,1个小时够了.下面是节选: 代码例子1: <html> <body> <h2>在 JavaScript 中创建 JSON 对象< ...

  5. linux下Apache+Svn环境搭建(五)

    在搭建之前先准备好如下包,建议去apache官网去下载:http://httpd.apache.org/ apr-1.4.6.tar.gzapr-util-1.4.1.tar.gzhttpd-2.2. ...

  6. Django模板遍历字典的方法

    使用Python + Django做Web开发时,有时需要在view中传递一个字典给模板(template),如何在模板中遍历字典呢? 下面介绍两种方法: views.py代码如下: dicts = ...

  7. 通过设置chrome浏览器解决跨域问题,在本地进行开发工作

    后端跨域权限无法打开,于是去网上找了下我这边能不能解决 现在的浏览器出于安全策略的限制,都是不允许跨域的,但是开发的时候经常需要一些别的域的接口,特别是一些接口不是自己能控制的时候,往往会造成开发困难 ...

  8. [leetcode]84.Largest Rectangle in Histogram ,O(n)解法剖析

    Given n non-negative integers representing the histogram's bar height where the width of each bar is ...

  9. PHP获取今天开始和结束的时间戳

    $t = time();$start = mktime(0,0,0,date("m",$t),date("d",$t),date("Y",$ ...

  10. C#学习笔记---区分StringWriter(Reader)和StreamWriter(Reader),TextWriter(Reader),BinaryWriter(Reader)

    1.TextWriter(Reader)分别是对连续字符系列处理的编写器(读写器),来自System.IO 2.StringWriter(Reader)继承TextWriter(Reader),它主要 ...