当前位置: 首页 > news >正文

网站开发建设培训宁德seo优化

网站开发建设培训,宁德seo优化,做网站邯郸,宁波网站推广厂家排名概念解释:(理解基本概念方可快速入手) 连接点(joinpoint) 被拦截到的点,因为Spring只支持方法类型的连接点,所以在Spring中连接点指的就是被拦截到的方法。 切入点(pointcut&#x…

 概念解释:(理解基本概念方可快速入手)

  1. 连接点(joinpoint)

    被拦截到的点,因为Spring只支持方法类型的连接点,所以在Spring中连接点指的就是被拦截到的方法。

  2. 切入点(pointcut)

    切入点是指我们要对哪些连接点进行拦截的定义

  3. 通知(advice)

    所谓通知指的就是指拦截到连接点之后要执行的代码,通知分为前置、后置、异常、最终、环绕通知五类

  4. 切面(aspect)

    是切入点和通知的结合

 通知顺序:

前置通知:aop:before
            后置通知:aop:after-returning【try】
            最终通知:aop:after【finally】
            异常通知:aop:after-throwing【catch】
            环绕通知:aop:around


            try{
                ...
                return aop:after-returning
            }catch(Exception e){
                ...
                aop:after-throwing
            }finally{
                ...
                aop:after
            }

切点表达式:
        格式:execution([修饰符] 返回值 报名.类名.方法名(参数))
        eg:execution(* com.by.service.*.*(..))

 实例演示:

pom.xml:

<dependencies><!--ioc--><dependency><groupId>org.springframework</groupId><artifactId>spring-context</artifactId><version>6.0.12</version></dependency><!--支持切点表达式AOP --><dependency><groupId>org.springframework</groupId><artifactId>spring-aspects</artifactId><version>5.1.8.RELEASE</version></dependency><dependency><groupId>org.slf4j</groupId><artifactId>slf4j-log4j12</artifactId><version>1.7.19</version></dependency></dependencies>

UserDaoImpl:

package com.by.dao;public class UserDaoImpl implements UserDao {@Overridepublic void addUser(){System.out.println("insert into tb_user......");}
}

UserServiceImpl:

package com.by.service;import com.by.dao.UserDao;public class UserServiceImpl implements UserService {private UserDao userDao;public void setUserDao(UserDao userDao) {this.userDao = userDao;}@Overridepublic void addUser(){userDao.addUser();System.out.println(8/0);}
}

MyLogActive:(增强类)

/** Copyright (c) 2020, 2024,  All rights reserved.**/
package com.by.advice;import org.aspectj.lang.ProceedingJoinPoint;/*** <p>Project: Spring - MyLogAdvice</p>* <p>Powered by scl On 2024-01-05 15:04:11</p>* <p>描述:<p>** @author 孙臣龙 [1846080280@qq.com]* @version 1.0* @since 17*/
public class MyLogAdvice {public void after() {System.out.println("最终通知、、、");}public void before() {System.out.println("前置通知、。、");}public void afterReturn(){System.out.println("后置通知");}public void afterThrowing(){System.out.println("异常通知");}public void around(ProceedingJoinPoint joinPoint) {try {System.out.println("前环绕通知。。。");joinPoint.proceed();System.out.println("后环绕通知。。。");} catch (Throwable e) {throw new RuntimeException(e);}}
}

 applicationContext.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:aop="http://www.springframework.org/schema/aop"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop.xsd"><bean id="userDao" class="com.by.dao.UserDaoImpl"></bean><bean id="userService" class="com.by.service.UserServiceImpl"><property name="userDao" ref="userDao"></property></bean><!--增强--><bean id="myLogAdvice" class="com.by.advice.MyLogAdvice"></bean><!--aop--><aop:config><!--切点--><aop:pointcut id="pointcut" expression="execution(* com.by.service.*.*(..))"/><!--切面--><aop:aspect ref="myLogAdvice"><aop:before method="before" pointcut-ref="pointcut"></aop:before><aop:after method="after" pointcut-ref="pointcut"></aop:after><aop:around method="around" pointcut-ref="pointcut"></aop:around><aop:after-returning method="afterReturn" pointcut-ref="pointcut"></aop:after-returning><aop:after-throwing method="afterThrowing" pointcut-ref="pointcut"></aop:after-throwing></aop:aspect></aop:config></beans>

没增强前结果展示:

增强之后结果展示:

http://www.wangmingla.cn/news/82002.html

相关文章:

  • 临沂网站优化公司淘宝关键词查询
  • 北京市政建设集团有限责任公司网站营销型网站有哪些
  • 只用ip做网站 不备案学生班级优化大师
  • 做网站哪家公司好seo页面优化技术
  • 网站ftp查询seo优化一般包括哪些内容
  • 网站建设ahxkjseo系统
  • 网站源码商城什么是核心关键词
  • 网站做支付按流量付费纵横seo
  • 2023年房地产行业分析搜索引擎优化工具有哪些
  • 成都医疗seo整站优化代写文案的软件
  • 网站建设领域的基本五大策略要学会百度导航最新版本免费下载
  • 专业网站建设的公司有趣的软文
  • 长春网站建设sok最好的免费信息发布平台
  • 只做网站不做app青海百度关键词seo
  • 山东网站建设公司哪家专业最新全国疫情消息
  • wordpress vr播放插件知乎关键词排名优化
  • 成都市网站建设供应商排名扬州seo推广
  • 上海装修公司前100名seo学校培训课程
  • 外贸网站建设官网自己搭建一个网站
  • 巴西网站后缀培训课程
  • 县级政府网站建设论文武汉网络广告推广服务
  • 9377传奇世界360优化大师官方下载
  • 深圳做h5网站制作杭州排名优化公司
  • 淘宝上做的网站靠谱吗北京网站优化公司
  • seo短视频网页入口引流在线观看网站淘宝关键词排名查询工具
  • 广州知名网站建设哪家好百度点击软件
  • 做黑彩网站会怎样处罚培训总结精辟句子
  • 石家庄网站建设推广电话长尾关键词挖掘工具
  • 上海找人做网站爱网站关键词挖掘工具
  • 外贸网站国际化怎么做百度指数与百度搜索量