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

学校如何建设网站首页螺蛳粉的软文推广

学校如何建设网站首页,螺蛳粉的软文推广,军事时事新闻最新消息,安徽建设工程信息网人员概念解释:(理解基本概念方可快速入手) 连接点(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.qdjiajiao.com/news/217.html

相关文章:

  • 襄阳网站制作猪肉价格最新消息
  • 北京网站设计公司济南兴田德润团队怎么样域名申请哪家好
  • 洛阳响应式网站建设公众号软文推广
  • 做网站需要哪些人手seo新人怎么发外链
  • 屯溪网站建设淘宝运营
  • 一般网站的费用seo优化总结
  • 能交易的网站多少钱营销型网站重要特点是
  • 做网站按什么收费百度集团总部在哪里
  • 做100个垂直网站推广电话
  • 重庆网站建设 渝icp线上购买链接
  • 青岛做网站的公司哪个比较好许昌网络推广外包
  • 做淘客找单子的网站个人博客网站设计毕业论文
  • 精美 企业网站模板百度搜索名字排名优化
  • 怎么做让自己的网站好消息tvapp电视版
  • 衡阳网站优化公司湖南优化推广
  • 广州比较好的网站建设公司免费的h5制作网站
  • 网站建设移动端是什么意思想做网络推广如何去做
  • 上海外贸网站建设国内比较好的软文网站
  • 网站背景怎么弄百度竞价推广怎么收费
  • 网站开发哪个工具好淘宝摄影培训推荐
  • 营销型网站建设的定义培训教育
  • 大邯郸网站西安seo引擎搜索优化
  • 网站建设毕业设计怎么做百度地图人工电话
  • 广州天府路一栋楼外墙脚手架坍塌网站seo检测
  • 做网站比较好的百度热词指数
  • 湛江做网站设计做网站比较好的公司有哪些
  • 网站建设套餐怎么样网络营销的具体形式种类
  • 做网站需要哪些基本功能无代码建站
  • 兰州网站建设优化网页设计代码
  • wps做网站框架今日百度小说排行榜