国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書(shū)等14項(xiàng)超值服

開(kāi)通VIP
jsp生成html靜態(tài)網(wǎng)頁(yè)
<%@ page contentType="text/html; charset=gb2312"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<%@ page import="org.apache.commons.fileupload.*" %>
<%@ page import="java.text.*" %>
<%@ page import="javax.servlet.*,javax.servlet.http.*"%>
<jsp:useBean id="conn" scope="page" class="DBLink.DBSQL"/>
<jsp:useBean id="ReadTemplates" scope="page" class="ball.news.ReadTemplates"/>
<jsp:useBean id="WriteHtml" scope="page" class="ball.news.WriteHtml"/>
<jsp:useBean id="ReplaceAll" scope="page" class="ball.news.ReplaceAll"/>
<%
//request.setCharacterEncoding("gb2312");

try{
String dir=request.getRealPath(".");
DiskFileUpload fu = new DiskFileUpload();


fu.setSizeMax(4194304); //設(shè)置文件大小. 這里文件只能上傳4M以內(nèi)的

fu.setSizeThreshold(4096); //設(shè)置緩沖大小.

fu.setRepositoryPath(dir+"/ball/news/images"); //設(shè)置臨時(shí)目錄.

List fileItems = fu.parseRequest(request); //解析請(qǐng)求,返回一個(gè)集合.

Iterator i = fileItems.iterator();
String fieldvalue="";
String ff = "";
String picname="false";
Object tt = "";
Vector v = new Vector();

while(i.hasNext())
{

FileItem fi = (FileItem)i.next();

if(fi.isFormField()) //這是用來(lái)確定是否為文件屬性,
{

String fieldName = fi.getFieldName(); //這里取得表單名
fieldvalue=fi.getString(); //這里取得表單值

v.addElement(fieldvalue);

}

else //這里開(kāi)始外理文件
{

File fullFile = new File(fi.getName());
ff = fullFile.getName();
String rr = "";


java.util.Date date2 = new java.util.Date();
SimpleDateFormat formatter = new SimpleDateFormat ("yyyyMMddHHmmss"); //取得時(shí)間
String str2 = formatter.format(date2);
StringTokenizer st = new StringTokenizer(ff,".");
if (st.hasMoreTokens()){
String test12 = st.nextToken();
rr = st.nextToken();
//System.out.println(rr);
}
if (rr.equals("")&&!rr.equals("gif")&&!rr.equals("jpg")&&!rr.equals("jpeg"))
{
picname = "false";
}

else
{
picname = str2+"."+rr; //以時(shí)間為圖片名稱

File savedFile = new File(getServletContext().getRealPath("/ball/news/images/"),picname);

fi.write(savedFile); //上傳到服務(wù)器
}
//System.out.println("picname------------------------"+picname);
}
//System.out.println("v------------------------"+v);
}
String[] flag = {"<temp_title>","<temp_date>","<temp_author>","<temp_content>","<str_Temp>","<temp_picture>"};

//將數(shù)據(jù)寫(xiě)入到數(shù)據(jù)庫(kù)
Object newtype1 = v.elementAt(0);
String t = newtype1.toString();
int newtype = Integer.parseInt(t);
Object rowid1 = v.elementAt(1);
String rowid = rowid1.toString();
Object title1 = v.elementAt(2);
String title = title1.toString();
Object content1 = v.elementAt(3);
String content = content1.toString();
// System.out.println(down);
java.util.Date date = new java.util.Date();
String strdate = date.toLocaleString();

java.util.Date StrDate1 = new java.util.Date();
String StrDate = StrDate1.toLocaleString(); // 新聞發(fā)布時(shí)間
//String newtype="0";
conn.openDB();
String sql = "select top 5 * from b_news where newtype="+newtype+" order by id desc";
String strTemp="<tr><td>相關(guān)新聞</td></tr>";
ResultSet rs = conn.executeQuery(sql);
while (rs.next())
{
String t2 = rs.getString(2);
String t4 = rs.getString(4);
strTemp += "<tr><td>";
strTemp +="<a href=../../../"+t4+">";
strTemp += t2;
strTemp +="</a>";
}
strTemp +="</td></tr>";
rs.close();


//讀取模板

String filePath = "";
filePath = request.getRealPath("\\ball\\news\\pnews.template");
String templateContent = null;
try{
templateContent = ReadTemplates.getTlpContent(filePath);
System.out.println(templateContent);
}
catch(Exception e)
{
System.out.println("error to template!");
}
//替換模板中的內(nèi)容
//System.out.println("picname--------------------------------"+picname);

templateContent = ReplaceAll.replace(templateContent,flag[0],title);
templateContent = ReplaceAll.replace(templateContent,flag[1],StrDate);
//templateContent = ReplaceAll.replace(templateContent,flag[2],editer);
templateContent = ReplaceAll.replace(templateContent,flag[3],content);
templateContent = ReplaceAll.replace(templateContent,flag[4],strTemp);
templateContent = ReplaceAll.replace(templateContent,flag[5],picname);

// 根據(jù)時(shí)間得文件名與路徑名

Calendar calendar = Calendar.getInstance();
String fileName = String.valueOf(calendar.getTimeInMillis()) +".html";
String pathName = request.getRealPath("ball/news")+"\\"+ calendar.get(Calendar.YEAR) + "\\"+ (calendar.get(Calendar.MONTH)+1) +"\\"+ calendar.get(Calendar.DAY_OF_MONTH)+"\\";
String url = calendar.get(Calendar.YEAR) + "/"+ (calendar.get(Calendar.MONTH)+1) +"/"+ calendar.get(Calendar.DAY_OF_MONTH)+"/";
url +=fileName;
//System.out.println(url);

try{
WriteHtml.save(templateContent,pathName,fileName);
}catch(Exception e){
System.out.println("error to html!-----------"+e.getMessage());
}


//寫(xiě)入數(shù)據(jù)庫(kù)
String sqlInsert = null;
if (!picname.equals("false")){
sqlInsert = "insert into b_news (title,content,url,picture,newtype,addtime,rowid) values (‘"+title+"‘,‘"+content+"‘,‘"+url+"‘,‘"+picname+"‘,‘"+newtype+"‘,getdate(),‘"+rowid+"‘)";
}
else
{
picname="images/"+picname;
sqlInsert = "insert into b_news (title,content,url,newtype,addtime,rowid) values (‘"+title+"‘,‘"+content+"‘,‘"+url+"‘,‘"+newtype+"‘,getdate(),‘"+rowid+"‘)";
}
//System.out.println("sql insert---------------"+sqlInsert);
conn.executeUpdate (sqlInsert);
}
catch(Exception e)
{
System.out.println("upload error------------------"+e.getMessage());
}



%>
<%out.println("新聞生成html成功了!");%>

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)
打開(kāi)APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
JSP生成靜態(tài)頁(yè)實(shí)踐及其設(shè)計(jì)思想 從數(shù)據(jù)庫(kù)讀取
文件上傳的JSP
Java面試題集
目標(biāo)URL存在跨站漏洞和目標(biāo)URL存在http host頭攻擊漏洞處理方案
JSP+ACCESS JDBC連接詳解
JAVA網(wǎng)站靜態(tài)化方法
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服