⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 temp.jsp

📁 新闻发布 由于程序采用了静态的HTML作为新闻存储的格式
💻 JSP
字号:
String templateContent = ReadTemplate.getInstance(filePath);

templateContent = ReplaceAll.replace(templateContent,flag[0],subject);
templateContent = ReplaceAll.replace(templateContent,flag[1],GetDate.getStringDate());
templateContent = ReplaceAll.replace(templateContent,flag[2],author);
templateContent = ReplaceAll.replace(templateContent,flag[3],from);
templateContent = ReplaceAll.replace(templateContent,flag[4],content);
templateContent = ReplaceAll.replace(templateContent,flag[5],sessionUser.getUsername());

// 根据时间得文件名与路径名
Calendar calendar = Calendar.getInstance();
String fileName = String.valueOf(calendar.getTimeInMillis()) +".shtml";
// 如果是linux系统请把 "\\" 改为 "/",谢谢
String pathName = application.getRealPath("./news")+"\\"+ calendar.get(Calendar.YEAR) + 
	"\\"+ (calendar.get(Calendar.MONTH)+1) +"\\"+ calendar.get(Calendar.DAY_OF_MONTH)+"\\";	

/**
* 写文件
*/
try{
	WriteHtml.save(templateContent,pathName,fileName);
}catch(WriteFileException we){
	throw new Exception("<li>新闻发布失败。可能是目录不具备IO操作权限。请与网管联系。");
}

News news = factory.getNews();
NewsFactory newsFactory = factory.getNewsFactory();

/**
* 添加到数据库
*/

news.setBoardID(id);
news.setEditer(sessionUser.getUsername());
news.setTitle(subject);
news.setNewsFile(calendar.get(Calendar.YEAR)+"/"+(calendar.get(Calendar.MONTH)+1)+"/"+ calendar.get(Calendar.DAY_OF_MONTH)+"/"+fileName);

newsFactory.add(news);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -