public interface Calculator {
public int add(int a, int b);
public int division(int a, int b);
}
import org.springframework.stereotype.Repository;
@Repository("calculator")
public class CalculatorImp implements Calculator {
@Override
public int add(int a, int b) {
System.out.println("add 方法执行了 ----> " + (a + b));
return (a + b);
}
@Override
public int division(int a, int b) {
System.out.println("division 方法执行了 ----> " + (a / b));
return (a / b);
}
}
public interface Calculator {
public int add(int a, int b);
public int division(int a, int b);
}
public class CalculatorImp implements Calculator {
@Override
public int add(int a, int b) {
System.out.println("add 方法执行了 ----> " + (a + b));
return (a + b);
}
@Override
public int division(int a, int b) {
System.out.println("division 方法执行了 ----> " + (a / b));
return (a / b);
}
}
import java.util.Arrays;
import java.util.List;
import org.aspectj.lang.JoinPoint;
public class LoggerAspect {
public void beforeAdvice(JoinPoint joinPoint) {
String methodName = joinPoint.getSignature().getName();
List args = Arrays.asList(joinPoint.getArgs());
System.out.println("Before 前置通知 : 方法名 【 " + methodName + " 】and args are " + args);
}
public void afterAdvice(JoinPoint joinPoint) {
String methodName = joinPoint.getSignature().getName();
List args = Arrays.asList(joinPoint.getArgs());
System.out.println("After 后置通知 : 方法名 【 " + methodName + " 】and args are " + args);
}
public void afterRunningAdvice(JoinPoint joinPoint, Object result) {
String methodName = joinPoint.getSignature().getName();
List args = Arrays.asList(joinPoint.getArgs());
System.out.println("AfterReturning 返回通知 : 方法名 【 " + methodName + " 】and args are " + args + " , result is " + result);
}
public void afterThrowingAdvice(JoinPoint joinPoint, Exception exception) {
String methodName = joinPoint.getSignature().getName();
System.out.println("AfterThrowing 异常通知 : 方法名 【 " + methodName + " 】and exception is " + exception);
}
}
import java.util.Arrays;
import java.util.List;
import org.aspectj.lang.ProceedingJoinPoint;
public class AroundAspect {
public Object aroundAdvice(ProceedingJoinPoint joinPoint) {
Object result = null;
String methodName = joinPoint.getSignature().getName();
List args = Arrays.asList(joinPoint.getArgs());
try {
System.out.println("@Around 前置通知 : 方法名 【 " + methodName + " 】and args are " + args);
result = joinPoint.proceed();
System.out.println("@Around 返回通知 : 方法名 【 " + methodName + " 】and args are " + args + " , result is " + result);
} catch (Throwable e) {
e.printStackTrace();
System.out.println("@Around 异常通知 : 方法名 【 " + methodName + " 】and exception is " + e);
}
System.out.println("@Around 后置通知 : 方法名 【 " + methodName + " 】and args are " + args);
return result;
}
}
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Main {
public static void main(String[] args) {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
Calculator calculator = (Calculator) ctx.getBean("calculator");
calculator.add(11, 12);
calculator.division(21, 3); // 测试时,将被除数换成0,可以测试AfterReturning ,After 和 AfterThrowing
ctx.close();
}
}
Before 前置通知 : 方法名 【 add 】and args are [11, 12]
add 方法执行了 ----> 23
After 后置通知 : 方法名 【 add 】and args are [11, 12]
AfterReturning 返回通知 : 方法名 【 add 】and args are [11, 12] , result is 23
Before 前置通知 : 方法名 【 division 】and args are [21, 3]
division 方法执行了 ----> 7
After 后置通知 : 方法名 【 division 】and args are [21, 3]
AfterReturning 返回通知 : 方法名 【 division 】and args are [21, 3] , result is 7
终端仿真器是一款用其它显示架构重现可视终端的计算机程序。换句话说就是终端仿真器能使哑终端看似像一台连接上了服务器的客户机。终端仿真器允许最终用户用文本用户界面和命令行来访问控制台和应用程序。(LCTT 译注:终端仿真器原意指对大型机-哑终端方式的模拟,不过在当今的 Linux 环境中,常指通过远程或本地方式连接的伪终端,俗称“终端”。)
你能从开源世界中找到大量的终端仿真器,它们
功能:在控制台每秒输出一次
代码:
package Main;
import javax.swing.Timer;
import java.awt.event.*;
public class T {
private static int count = 0;
public static void main(String[] args){
1,获取样式属性值
top 与顶部的距离
left 与左边的距离
right 与右边的距离
bottom 与下边的距离
zIndex 层叠层次
例子:获取左边的宽度,当css写在body标签中时
<div id="adver" style="position:absolute;top:50px;left:1000p
spring data jpa 支持以方法名进行查询/删除/统计。
查询的关键字为find
删除的关键字为delete/remove (>=1.7.x)
统计的关键字为count (>=1.7.x)
修改需要使用@Modifying注解
@Modifying
@Query("update User u set u.firstna
项目中controller的方法跳转的到ModelAndView类,一直很好奇spring怎么实现的?
/*
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* yo
(1)npm是什么
npm is the package manager for node
官方网站:https://www.npmjs.com/
npm上有很多优秀的nodejs包,来解决常见的一些问题,比如用node-mysql,就可以方便通过nodejs链接到mysql,进行数据库的操作
在开发过程往往会需要用到其他的包,使用npm就可以下载这些包来供程序调用
&nb
Controller层的拦截器继承于HandlerInterceptorAdapter
HandlerInterceptorAdapter.java 1 public abstract class HandlerInterceptorAdapter implements HandlerIntercep