package aop;
import javax.servlet.http.HttpSession;
import org.aspectj.lang.ProceedingJoinPoint;
public class PowerAspect {
// 切面
public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
long time = System.currentTimeMillis();
Object retVal = pjp.proceed();
time = System.currentTimeMillis() - time;
// Object args[]=pjp.getArgs();
//pjp.get
// HttpSession session=(HttpSession)args[0];
//
// for(int i=0;i<args.length;i++){
//
// //System.out.println("---------->"+args[i].getClass()+"--------->"+args[i].);
//
// }
System.out.println(pjp.getTarget().getClass().getName()+"---->"+pjp.getSignature().getName()+"---->"+"process time--->: " + time + " ms");
//System.out.println("----->"+retVal);
//return "操作失败,权限不够!";
return retVal;
}
}
<!-- spring aop -->
<aop:config>
<aop:aspect id="aspect" ref="powerAspect">
<!--定义切入点 -->
<aop:pointcut id="servicePointcut"
expression="execution(* serviceimp.*.*(..))" />
<!-- 定义通知 -->
<aop:around pointcut-ref="servicePointcut"
method="doAround" />
</aop:aspect>
</aop:config>
<!-- 定义一个切面 -->
<bean id="powerAspect" class="aop.PowerAspect"></bean>
---------------------------------------------------------------------------
package util;
public class Page {
int totalRowsAmount; // 总行数
int pageSize = 10; // 每页行数
int currentPage = 1; // 当前页码
int nextPage;
int previousPage;
int totalPages; // 总页数
boolean hasNext; // 是否有下一页
boolean hasPrevious; // 是否有前一页
String description;
int pageStartRow;
int pageEndRow;
int p_start;
int p_end;
public Page() {
}
public Page(int totalRows, int pageSize) {
// this.totalRowsAmount=totalRows;
setPageSize(pageSize);
setTotalRowsAmount(totalRows);
}
public void setTotalRowsAmount(int i) {
this.totalRowsAmount = i;
if (this.totalRowsAmount % this.pageSize == 0)
totalPages = this.totalRowsAmount / this.pageSize;
else
totalPages = this.totalRowsAmount / this.pageSize + 1;
}
public void setCurrentPage(int i, String url) {
if (i < 1)
currentPage = 1;
else if (i > totalPages)
currentPage = totalPages;
else
currentPage = i;
nextPage = currentPage + 1;
previousPage = currentPage - 1;
// // 计算当前页开始行和结束行
if (currentPage * pageSize <= totalRowsAmount) {
pageEndRow = currentPage * pageSize;
pageStartRow = pageEndRow - pageSize + 1;
if (pageStartRow <= 0)
pageStartRow = 0;
} else {
pageEndRow = totalRowsAmount;
pageStartRow = pageSize * (totalPages - 1) + 1;
}
// 是否存在前页和后页
if (currentPage >= totalPages)
hasNext = false;
else
hasNext = true;
if (currentPage <= 1)
hasPrevious = false;
else
hasPrevious = true;
p_start = currentPage - 5; // 10条
if (p_start <= 0)
p_start = 1;
p_end = p_start + 10;
if (p_end > totalPages)
p_end = totalPages;
p_start = p_end - 10;
if (p_start <= 0)
p_start = 1;
this.description = "共有" + this.getTotalRowsAmount() + "条记录,显示"
+ this.getPageStartRow() + "到" + this.getPageEndRow();
this.description += " <a href=" + url + "&page=1>首页</a>";
if (this.isHasPrevious())
this.description += " <a href=" + url + "&page="
+ (this.currentPage - 1) + ">上一页</a>";
else
this.description += " 上一页";
if (this.isHasNext())
this.description += " <a href=" + url + "&page="
+ (this.currentPage + 1) + ">下一页</a>";
else
this.description += " 下一页";
this.description += " <a href=" + url + "&page="
+ this.totalPages + ">尾页</a>";
this.description += " 跳转至";
this.description += "<select id='page' onchange='go()'>";
for (int k = 1; k <= this.totalPages; k++) {
if (k == this.currentPage)
this.description += "<option value='" + k
+ "' selected='selected'>" + k + "</option>";
else
this.description += "<option value='" + k + "'>" + k
+ "</option>";
}
this.description += "</select>";
this.description += "页";
// System.out.println(this.description());
}
public void setCurrentPage01(int i) {
if (i < 1)
currentPage = 1;
else if (i > totalPages)
currentPage = totalPages;
else
currentPage = i;
p_start = currentPage - 5; // 10条
if (p_start < 0)
p_start = 0;
p_end = p_start + 10;
if (p_end > totalPages)
p_end = totalPages;
p_start = p_end - 10;
if (p_start < 0)
p_start = 0;
this.description += "<a href='#' onclick=\"return go_page('"
+ (currentPage - 1) + "')\">上一页</a>";
for (int j = p_start; j < p_end; j++) {
if ((j + 1) != currentPage) {
this.description += "<a href='#' onclick=\"return go_page('"
+ (j + 1) + "')\"> " + (j + 1) + " </a>";
} else {
this.description += "<a href='#' style='background:#B1369C'' onclick=\"return go_page('"
+ (j + 1)
+ "')\"><font color='#FFFFFF' style='background:#B1369C'> "
+ (j + 1) + " </font></a>";
}
}
this.description += "<a href='#' onclick=\"return go_page('"
+ (currentPage + 1) + "')\">下一页</a>";
}
public int getCurrentPage() {
return currentPage;
}
public boolean isHasNext() {
return hasNext;
}
public boolean isHasPrevious() {
return hasPrevious;
}
public int getNextPage() {
return nextPage;
}
public int getPageSize() {
return pageSize;
}
public int getPreviousPage() {
return previousPage;
}
public int getTotalPages() {
return totalPages;
}
public int getTotalRowsAmount() {
return totalRowsAmount;
}
public void setHasNext(boolean b) {
hasNext = b;
}
public void setHasPrevious(boolean b) {
hasPrevious = b;
}
public void setNextPage(int i) {
nextPage = i;
}
public void setPageSize(int i) {
pageSize = i;
}
public void setPreviousPage(int i) {
previousPage = i;
}
public void setTotalPages(int i) {
totalPages = i;
}
public int getPageEndRow() {
return pageEndRow;
}
public int getPageStartRow() {
return pageStartRow;
}
public String getDescription() {
return description;
}
public int getP_end() {
return p_end;
}
public void setP_end(int p_end) {
this.p_end = p_end;
}
public int getP_start() {
return p_start;
}
public void setP_start(int p_start) {
this.p_start = p_start;
}
public void setCurrentPage(int currentPage) {
this.currentPage = currentPage;
}
public void setDescription(String description) {
this.description = description;
}
public void setPageEndRow(int pageEndRow) {
this.pageEndRow = pageEndRow;
}
public void setPageStartRow(int pageStartRow) {
this.pageStartRow = pageStartRow;
}
}
分享到:
相关推荐
3、对spring aop认识模糊的,不清楚如何实现Java 自定义注解的 4、想看spring aop 注解实现记录系统日志并入库等 二、能学到什么 1、收获可用源码 2、能够清楚的知道如何用spring aop实现自定义注解以及注解的逻辑...
spring aop jar 包
描述一下Spring AOP? 在Spring AOP中关注点(concern)和横切关注点(cross-cutting concern)有什么不同? AOP有哪些可用的实现? Spring中有哪些不同的通知类型(advice types)? Spring AOP 代理是什么? 引介...
基于注解实现SpringAop基于注解实现SpringAop基于注解实现SpringAop
死磕Spring之AOP篇 - Spring AOP两种代理对象的拦截处理(csdn)————程序
spring aop切面拦截指定类和方法实现流程日志跟踪 一般情况下,在不侵入业务代码的情况下,需要做流程日志跟踪是比较合理的 采用springaop切面思想
AOP的意思就是面向切面编程。本文主要是通过梳理JDK中自带的反射机制,实现 AOP动态代理模式,这也是Spring AOP 的实现原理
springaop依赖的jar包,spring版本2.5.6,如果需要,可以下载使用,欢迎各位评论指出不足
springAOP配置实现动态代理,有利于熟悉动态代理原理,深入了解spring。
Spring源码最难问题:当Spring AOP遇上循环依赖.docx
spring aop的demo spring aop的demo
Spring AOP 入门 作者:廖雪峰
spring aop spring aop spring aop spring aop spring aop spring aop spring aop spring aop spring aop
Spring AOP 日志管理 实例LoggingThrowsAdvice.java
Spring AOP 几个不同使用方法的完整例子,使用Junit4c测试, 在我的博客上有不同配置组合的说明,可以参考
Spring AOP的实现机制中文版,动态代理及原理,自定义类加载器
Spring AOP简单demo 入门级的 advice
springAOP详解
spring aop 经典例子(原创),无论新手还是老手,可以快速对Spring AOP有个总体的认识。基于JDK1.6,Spring2.0.5,Eclipse IDE。
springaop多数据库读写分离