("/ball/news/images/"),picname);
fi.write(savedFile); //上传到服务器
}
//System.out.println("picname------------------------"+picname);
}
//System.out.println("v------------------------"+v);
}
String[] flag = {"<temp_title>","<temp_date>","<temp_author>","<temp_content>","<str_Temp>","<temp_picture>"};
//将数据写入到数据库
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(); // 新闻发布时间
//String newtype="0";
conn.openDB();
String sql = "select top 5 * from b_news where newtype="+newtype+" order by id desc";
String strTemp="<tr><td>相关新闻</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!");
}
//替换模板中的内容
//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);
// 根据时间得文件名与路径名
Calendar calendar = Calendar.getInstance();
String fileName = String.valueOf(calendar.getTimeInMillis()) +".html";
String pathName = request.getRealPath("ball/news")+"\\"+ calendar.get
fi.write(savedFile); //上传到服务器
}
//System.out.println("picname------------------------"+picname);
}
//System.out.println("v------------------------"+v);
}
String[] flag = {"<temp_title>","<temp_date>","<temp_author>","<temp_content>","<str_Temp>","<temp_picture>"};
//将数据写入到数据库
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(); // 新闻发布时间
//String newtype="0";
conn.openDB();
String sql = "select top 5 * from b_news where newtype="+newtype+" order by id desc";
String strTemp="<tr><td>相关新闻</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!");
}
//替换模板中的内容
//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);
// 根据时间得文件名与路径名
Calendar calendar = Calendar.getInstance();
String fileName = String.valueOf(calendar.getTimeInMillis()) +".html";
String pathName = request.getRealPath("ball/news")+"\\"+ calendar.get
| 对此文章发表了评论 |
