六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 15|回复: 0

spring aop

[复制链接]

升级  68.8%

278

主题

278

主题

278

主题

进士

Rank: 4

积分
844
 楼主| 发表于 2013-2-3 11:18:45 | 显示全部楼层 |阅读模式
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;elsetotalpages = this.totalrowsamount / this.pagesize + 1;}public void setcurrentpage(int i, string url) {if (i < 1)currentpage = 1;else if (i > totalpages)currentpage = totalpages;elsecurrentpage = 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;elsehasnext = true;if (currentpage <= 1)hasprevious = false;elsehasprevious = 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>";elsethis.description += "  上一页";if (this.ishasnext())this.description += "  <a href=" + url + "&page="+ (this.currentpage + 1) + ">下一页</a>";elsethis.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>";elsethis.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;elsecurrentpage = 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;}}
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表