From e8d2d33d47f744e4e81fd03b4ff64956761dba0a Mon Sep 17 00:00:00 2001 From: luoxiang <2806718453@qq.com> Date: Tue, 8 Jan 2019 22:05:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0README.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spring/spring-aop-annotation/README.md | 69 +++++++++++++++++++++- spring/spring-aop/README.md | 65 ++++++++++++++++++++ spring/springmvc-base-annotation/README.md | 4 -- spring/springmvc-base/README.md | 4 -- 4 files changed, 133 insertions(+), 9 deletions(-) diff --git a/spring/spring-aop-annotation/README.md b/spring/spring-aop-annotation/README.md index 6b045a7..26df9b0 100644 --- a/spring/spring-aop-annotation/README.md +++ b/spring/spring-aop-annotation/README.md @@ -166,4 +166,71 @@ public class AopTest { - 优先级高的切面在切入方法前执行的通知(before)会优先执行,但是位于方法后执行的通知(after,afterReturning)反而会延后执行,类似于同心圆原理。 -
\ No newline at end of file +
+ + + +## 附: 关于切面表达式的说明 + +切面表达式遵循以下格式: + +```shell +execution(modifiers-pattern? ret-type-pattern declaring-type-pattern?name-pattern(param-pattern) + throws-pattern?) +``` + +- 除了返回类型模式,名字模式和参数模式以外,所有的部分都是可选的; +- `*`,它代表了匹配任意的返回类型; +- `()` 匹配了一个不接受任何参数的方法, 而 `(..)` 匹配了一个接受任意数量参数的方法(零或者更多)。 模式 `(*)` 匹配了一个接受一个任何类型的参数的方法。 模式 `(*,String)` 匹配了一个接受两个参数的方法,第一个可以是任意类型,第二个则必须是String类型。 + +下面给出一些常见切入点表达式的例子。 + +- 任意公共方法的执行: + + ```java + execution(public * *(..)) + ``` + +- 任何一个以“set”开始的方法的执行: + + ```java + execution(* set*(..)) + ``` + +- `AccountService` 接口的任意方法的执行: + + ```java + execution(* com.xyz.service.AccountService.*(..)) + ``` + +- 定义在service包里的任意方法的执行: + + ```java + execution(* com.xyz.service.*.*(..)) + ``` + +- 定义在service包或者子包里的任意方法的执行: + + ```java + execution(* com.xyz.service..*.*(..)) + ``` + +- 在service包里的任意连接点(在Spring AOP中只是方法执行) : + + ```java + within(com.xyz.service.*) + ``` + +- 在service包或者子包里的任意连接点(在Spring AOP中只是方法执行) : + + ``` + within(com.xyz.service..*) + ``` + +- 实现了 `AccountService` 接口的代理对象的任意连接点(在Spring AOP中只是方法执行) : + + ``` + this(com.xyz.service.AccountService) + ``` + +更多表达式可以参考官方文档:[Declaring a Pointcut](https://docs.spring.io/spring/docs/5.1.3.RELEASE/spring-framework-reference/core.html#aop-pointcuts) \ No newline at end of file diff --git a/spring/spring-aop/README.md b/spring/spring-aop/README.md index b3e2364..e5acbdc 100644 --- a/spring/spring-aop/README.md +++ b/spring/spring-aop/README.md @@ -160,3 +160,68 @@ public class AopTest { ``` + +## 附: 关于切面表达式的说明 + +切面表达式遵循以下格式: + +```shell +execution(modifiers-pattern? ret-type-pattern declaring-type-pattern?name-pattern(param-pattern) + throws-pattern?) +``` + +- 除了返回类型模式,名字模式和参数模式以外,所有的部分都是可选的; +- `*`,它代表了匹配任意的返回类型; +- `()` 匹配了一个不接受任何参数的方法, 而 `(..)` 匹配了一个接受任意数量参数的方法(零或者更多)。 模式 `(*)` 匹配了一个接受一个任何类型的参数的方法。 模式 `(*,String)` 匹配了一个接受两个参数的方法,第一个可以是任意类型,第二个则必须是String类型。 + +下面给出一些常见切入点表达式的例子。 + +- 任意公共方法的执行: + + ```java + execution(public * *(..)) + ``` + +- 任何一个以“set”开始的方法的执行: + + ```java + execution(* set*(..)) + ``` + +- `AccountService` 接口的任意方法的执行: + + ```java + execution(* com.xyz.service.AccountService.*(..)) + ``` + +- 定义在service包里的任意方法的执行: + + ```java + execution(* com.xyz.service.*.*(..)) + ``` + +- 定义在service包或者子包里的任意方法的执行: + + ```java + execution(* com.xyz.service..*.*(..)) + ``` + +- 在service包里的任意连接点(在Spring AOP中只是方法执行) : + + ```java + within(com.xyz.service.*) + ``` + +- 在service包或者子包里的任意连接点(在Spring AOP中只是方法执行) : + + ``` + within(com.xyz.service..*) + ``` + +- 实现了 `AccountService` 接口的代理对象的任意连接点(在Spring AOP中只是方法执行) : + + ``` + this(com.xyz.service.AccountService) + ``` + +更多表达式可以参考官方文档:[Declaring a Pointcut](https://docs.spring.io/spring/docs/5.1.3.RELEASE/spring-framework-reference/core.html#aop-pointcuts) \ No newline at end of file diff --git a/spring/springmvc-base-annotation/README.md b/spring/springmvc-base-annotation/README.md index e508751..a9111ad 100644 --- a/spring/springmvc-base-annotation/README.md +++ b/spring/springmvc-base-annotation/README.md @@ -1,10 +1,6 @@ # springmvc基础(基于注解) -**开发环境:IDEA** -**spring版本:5.1.3.RELEASE** - -**本部分内容官方文档链接:[Web Servlet](https://docs.spring.io/spring/docs/5.1.3.RELEASE/spring-framework-reference/web.html#spring-web)** ## 一、搭建hello spring工程 diff --git a/spring/springmvc-base/README.md b/spring/springmvc-base/README.md index a3929f0..16c0fb3 100644 --- a/spring/springmvc-base/README.md +++ b/spring/springmvc-base/README.md @@ -1,10 +1,6 @@ # springmvc基础(基于xml配置) -**开发环境:IDEA** -**spring版本:5.1.3.RELEASE** - -**本部分内容官方文档链接:[Web Servlet](https://docs.spring.io/spring/docs/5.1.3.RELEASE/spring-framework-reference/web.html#spring-web)** ## 一、搭建hello spring工程