spring aop

   
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 += "&amp;nbsp;&amp;nbsp;<a href=" + url + "&amp;page=1>首页</a>";		if (this.ishasprevious())			this.description += "&amp;nbsp;&amp;nbsp;<a href=" + url + "&amp;page="					+ (this.currentpage - 1) + ">上一页</a>";		else			this.description += "&amp;nbsp;&amp;nbsp;上一页";		if (this.ishasnext())			this.description += "&amp;nbsp;&amp;nbsp;<a href=" + url + "&amp;page="					+ (this.currentpage + 1) + ">下一页</a>";		else			this.description += "&amp;nbsp;&amp;nbsp;下一页";		this.description += "&amp;nbsp;&amp;nbsp;<a href=" + url + "&amp;page="				+ this.totalpages + ">尾页</a>";		this.description += "&amp;nbsp;&amp;nbsp;跳转至";		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) + "')\">&amp;nbsp;" + (j + 1) + "&amp;nbsp;</a>";			} else {				this.description += "<a href='#' style='background:#b1369c'' onclick=\"return go_page('"						+ (j + 1)						+ "')\"><font color='#ffffff' style='background:#b1369c'>&amp;nbsp;"						+ (j + 1) + "&amp;nbsp;</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;	}}
 

你可能感兴趣的:(java,工作)