补(2005-11-12)整理
最常见的应用:网站的浏览数显示
帖上项目中的代码
//运用中可依据实际情况补充入口参数
public static String getCounterHTML(String strText,int intCount) throws Exception{
String strReturnValue="";
strReturnValue = "<table width='200' border='0' align='center' cellpadding='0' cellspacing='0'>\r\n";
strReturnValue = strReturnValue+ "<td align='right'>"+strText+"</td>";
strReturnValue = strReturnValue+"<td width='4' align='left'>"
strReturnValue = strReturnValue+"<img src='jsq001.gif' width='4' height='20'></td>\r\n";
strReturnValue = strReturnValue+"<td valign='bottom' background='jsq002.gif'>\r\n";
strReturnValue = strReturnValue+"<table width='100%' border='0' cellpadding='0' cellspacing='0'>\r\n";
strReturnValue = strReturnValue+"<tr align='center'>\r\n";
String strCount = String.valueOf(intCount);
int bottomcount = strCount.length()>6?strCount.length():6;
for(int i=0;i<bottomcount;i++){
String strShowNum = "";
if(6-strCount.length()>0){
if(i<6-strCount.length()){
strShowNum = "0";
}
else{
strShowNum = String.valueOf(strCount.charAt(i -(6 - strCount.length())));
}
}else{
strShowNum = String.valueOf(strCount.charAt(i));
}
strReturnValue = strReturnValue+"<td>"+strShowNum+"</td>";
if(i!=(strCount.length()>6?strCount.length():6)-1){
strReturnValue = strReturnValue+"<td width=2><img src='jsq003.gif' width=2 height=14></td>";
}
}
strReturnValue = strReturnValue+"</tr></table></td>\r\n";
strReturnValue = strReturnValue+"<td width='5'><img src='jsq004.gif' width='5' height='20'></td>\r\n";
strReturnValue = strReturnValue+"</tr></table>\r\n";
return strReturnValue;
}
需要用到四张图片:
jsq001.gif
jsq002.gif
jsq003.gif
jsq004.gif