日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

JSP初級教程之跟我學(xué)JSP(六)(2)_JSP教程

編輯Tag賺U幣
教程Tag:暫無Tag,歡迎添加,賺取U幣!

推薦:JSP初級教程之跟我學(xué)JSP(五)
第五章 jsp 分頁功能的實現(xiàn) 經(jīng)過上面的學(xué)習(xí)我漸漸熟悉了對 數(shù)據(jù)庫 的操作,留言板的功能也不斷的完善,隨著留言的增加信息的目錄越來越長了,現(xiàn)在需要實現(xiàn)一個分頁功能了,我嘗試自己解決這個問題。 1、我應(yīng)該把它的關(guān)鍵部分封裝成一個bean,使它盡可能的能


//得到代表數(shù)值的柱的各自高度,實際數(shù)值*columnMaxHeight/max
int columnWidth[]=new int[num];//不定長,柱的長度
for (int k=0;k<num;k++)
columnWidth[k]=(Datas[k]*columnMaxWidth)/max;//取整

frameSecondHeight=(sp+columnHeight)*num+10;//+10為了留出一塊底邊
imageHeight=frameSecondHeight+frameFirstHeight+frameSpace+10;//多加10為了畫陰影

PictureBean chartGraphics = new PictureBean();
chartGraphics.image = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB); 
Graphics g = chartGraphics.image.getGraphics();
g.setColor(Color.white);
g.fillRect(0,0,imageWidth,imageHeight);//用白色涂整個圖
Color frameFirstColor = new Color(20,50,100);
Color columnColor = new Color(153,19,19);
Color shadowColor = new Color(200,200,200);
g.setColor(shadowColor);
g.fillRect(0+7,0+7,frameFirstWidth,frameFirstHeight);//陰影在原框基礎(chǔ)上移7
g.setColor(Color.white);
g.drawRect(0,0,frameFirstWidth,frameFirstHeight);//畫第一個框
g.setColor(frameFirstColor);
g.fillRect(0+1,0+1,frameFirstWidth-1,frameFirstHeight-1);
g.setFont(new Font("仿體", 0 , 14));
g.setColor(Color.white);
g.drawString(Title,10,18);//寫字
g.drawString(SStr,300,18);

int frameSecondY=1+frameFirstHeight+frameSpace;
g.setColor(shadowColor);
g.fillRect(0+7,frameSecondY+7,frameSecondWidth,frameSecondHeight);//陰影在原框基礎(chǔ)上移7
g.setColor(Color.black);
g.drawRect(0,frameSecondY,frameSecondWidth,frameSecondHeight);//畫第二個框
g.setColor(Color.yellow);
g.fillRect(0+1,frameSecondY+1,frameSecondWidth-1,frameSecondHeight-1);//填充第二個框

for(int l=0;l<num;l++)
{
g.setColor(Color.black);
int textY=frameSecondY+20+(sp+columnHeight)*l;
g.drawString(name[l]+"("+datas[l]+")",0+10,textY);//寫文字
if (columnWidth[l]!=0)
{
g.setColor(columnColor);
g.drawRect(10,textY+5,columnWidth[l],columnHeight);//畫柱的外框//框的上邊離文字的底邊為5
g.fillRect(10+2,textY+5+2,columnWidth[l]-3,columnHeight-3);//畫柱
}
}
chartGraphics.createImage(fileLocation);
}
}
--------------------------------------------------------------------------------
但是接下來出現(xiàn)了一個讓我難以忍受的事:自做聰明的瀏覽器緩存使得頁面無法在短時間內(nèi)更新圖片——輸入2004,顯示了2004的圖片,馬上再輸入2005,可是顯示的仍然是2004的圖片,但這時硬盤目錄下的圖片已經(jīng)是2005的圖片了,一般來說兩次操作時間間隔大約少于3秒,則總是顯示緩存里的那張圖。這個問題困擾我很長時間,問了很多人試了很多方法都沒有解決了。
很顯然上面提到的第二個方法不存在此問題,我決定采用這種方法,所以我不得不回頭研究它的代碼,之后我發(fā)現(xiàn)這幾句代碼是顯示圖片的關(guān)鍵,而最下面的三句是和顯示圖有關(guān)的:
---------------------------------------------------------
response.setContentType("image/jpeg");
BufferedImage bi = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB);
Graphics2D biContext = bi.createGraphics();

…… 

分享:JSP初級教程之跟我學(xué)JSP(四)
第四章我的第一個 Javabean 程序 一、先看看如何取當(dāng)前時間并顯示的代碼: ------------------------------------------------ % java.text.SimpleDateFormatformatter=newjava.text.SimpleDateFormat(yyyy-MM-ddHH:mm:ss); java.util.DatecurrentTime=ne

來源:模板無憂//所屬分類:JSP教程/更新時間:2010-03-10
相關(guān)JSP教程