資源簡(jiǎn)介
可以通過(guò)一個(gè)java的類(lèi),來(lái)讀取數(shù)據(jù)庫(kù)來(lái)控制圖片顯示內(nèi)容。。
代碼片段和文件信息
package?com.kanba.forpage;
import?java.sql.Connection;
import?java.sql.Statement;
import?java.sql.ResultSet;
import?java.sql.SQLException;
import?java.util.ArrayList;
import?java.util.List;
import?java.util.Vector;
import?com.kanba.connection.Conn;
public?class?For_homePageSet?{
public?String?show_picForIndex(){//返回圖片滾動(dòng)播放代碼
String?content=““;
int?count=0;
try{//檢測(cè)數(shù)據(jù)庫(kù)中是否有輪播圖片
Connection?con=new?Conn().getConnection();
Statement?stmt=con.createStatement();
String?sql=“select?count(*)?from?pic_forhomepage?where?is_show=1?and?pic_pos=‘index.jsp‘?“;
ResultSet?rs=stmt.executeQuery(sql);
if(rs.next()){
count=rs.getInt(1);
}
rs.close();stmt.close();con.close();
}catch(SQLException?e){
e.printStackTrace();
}
if(count!=0){//有輪播圖片設(shè)置,則執(zhí)行
try{//檢測(cè)數(shù)據(jù)庫(kù)中是否有輪播圖片
Connection?con=new?Conn().getConnection();
Statement?stmt=con.createStatement();
String?sql=“select?pic_namepic_linkpic_url?from?pic_forhomepage?where?is_show=1?and?pic_pos=‘index.jsp‘?“;
ResultSet?rs=stmt.executeQuery(sql);
int?k=1;
String?imgUrl=“imgUrl“;
String?imgtext=“imgtext“;
String?imglink=“imglink“;
String?sign=“+\“|\“+“;
String?newurl=““;
String?newlink=““;
String?newtext=““;
String?var_pic=“var?pics=“;
String?var_links=“var?links=“;
String?var_text=“var?texts=“;
String?topcontent=““;
String?middlecontent=““;
while(rs.next()){
newurl=imgUrl+k;
newlink=imglink+k;
newtext=imgtext+k;
newurl=“\““+rs.getString(“pic_url“)+“\“;“;
newlink=“escape(\““+rs.getString(“pic_link“)+“\“);“;
newtext=“\““+rs.getString(“pic_name“)+“\“;“;
topcontent+=imgUrl+k+“=“+newurl+imglink+k+“=“+newlink+imgtext+k+“=“+newtext;
k++;
}
rs.close();stmt.close();con.close();
for(int?i=1;i<=count;i++){
newurl=imgUrl+i;
newlink=imglink+i;
newtext=imgtext+i;
if(i!=count){
var_pic+=newurl+sign;
var_links+=newlink+sign;
var_text+=newtext+sign;
}else{
var_pic+=newurl;
var_links+=newlink;
var_text+=newtext;
}
}
middlecontent=var_pic+“;?“+var_links+“;?“+var_text+“;?“;
content=topcontent+middlecontent;
}catch(SQLException?e){
e.printStackTrace();
}
}
//這里你可以設(shè)置FLASH的長(zhǎng)度和高度。
String?flash_set=“var?focus_width=327;?var?focus_height=235;??var?text_height=20;?var?swf_height?=?focus_height+text_height;“;
content+=flash_set;
return?content;
}
}
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件??????10550??2008-11-17?10:39??picRround\focus.swf
?????文件???????2610??2008-12-28?17:11??picRround\For_homePageSet.java
?????文件???????1324??2008-12-28?17:08??picRround\pic_round.jsp
?????文件????????888??2008-12-28?17:13??picRround\readme.txt
?????目錄??????????0??2008-12-28?17:11??picRround
-----------?---------??----------?-----??----
????????????????15372????????????????????5
評(píng)論
共有 條評(píng)論