JSP如何由动态页面生成静态页面?而且能时常进行静态页更新
解决方案 »
- <s:if test="#userList!=null">加#号与不加#号有什么区别?
- spring+struts2+hibernate开发,Action遇到错误。
- jsp传值问题
- Tomcat 服务问题 求助
- <a href="/*.do?id=112">1111111</a>怎样得到112
- struts+Hibernate上传三个二进制文件到数据库
- htm页 运行javascript在本地运行正常显示 服务器上就出不来 帮忙解决下
- hibernate 拦截器与监听器
- 文件读写的代码谁有,共享一下
- 请问,resultset.getFetchSize ()是派什么用场的?
- 有兴趣的朋友来聊一聊,生成静态页面后的分页问题
- 新手:请教如何注销?
定时重写一个文件,如jpg文件第二种是通过引用oscache在内存中生成一个缓存
具体使用方法 自己在网上查一下
<%
try{
String title="This is Title";
String content="This is Content Area";
String editer="LaoMao";
String filePath = "";
filePath = request.getRealPath("/")+"test/template.htm";
//out.print(filePath+"<br/>");
String templateContent="";
FileInputStream fileinputstream = new FileInputStream(filePath);//读取模块文件
int lenght = fileinputstream.available();
byte bytes[] = new byte[lenght];
fileinputstream.read(bytes);
fileinputstream.close();
templateContent = new String(bytes);
//out.print(templateContent);
templateContent=templateContent.replaceAll("###title###",title);
templateContent=templateContent.replaceAll("###content###",content);
templateContent=templateContent.replaceAll("###author###",editer);//替换掉模块中相应的地方
//out.print(templateContent);
// 根据时间得文件名
Calendar calendar = Calendar.getInstance();
String fileame = String.valueOf(calendar.getTimeInMillis()) +".html";
fileame = request.getRealPath("/")+fileame;//生成的html文件保存路径
FileOutputStream fileoutputstream = new FileOutputStream(fileame);//建立文件输出流
byte tag_bytes[] = templateContent.getBytes();
fileoutputstream.write(tag_bytes);
fileoutputstream.close();
}
catch(Exception e){
out.print(e.toString());
}%>2. template.htm<html>
<head>
<title>###title###</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href="../css.css" rel=stylesheet type=text/css>
</head><body>
<table width="500" border="0" align="center" cellpadding="0" cellspacing="2">
<tr>
<td align="center">###title###</td>
</tr>
<tr>
<td align="center">author:###author### </td>
</tr>
<tr>
<td>###content###
</td>
</tr></table>
</body>
</html>