怎样把jsp转换为html

liuzhijie0451 2007-07-24 02:55:31
好象是index.jsp?id=5 转换为index.html大概是这个意思,就是把动态的代码转换为静态的
...全文
979 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
ITshu 2007-08-03
  • 打赏
  • 举报
回复
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<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>
ITshu 2007-08-03
  • 打赏
  • 举报
回复
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.util.*,java.io.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>

<%
try{
String title="This is Title";
String content="This is Content Area";
String editer="LaoMao";
String filePath = "";
filePath = request.getRealPath("/")+"template.html";
//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());
}
%>

</body>
</html>
zhang82118 2007-08-03
  • 打赏
  • 举报
回复
学习
buyaowen 2007-07-31
  • 打赏
  • 举报
回复
同意楼上的
laughter75 2007-07-31
  • 打赏
  • 举报
回复
没有办法的办法 用URLConnection 打开你的index......读出流,写入index.html文件,就ok了
mywanpi 2007-07-31
  • 打赏
  • 举报
回复
这个有用吗?
kulin3422 2007-07-27
  • 打赏
  • 举报
回复
学习
sureyor 2007-07-27
  • 打赏
  • 举报
回复
1.url rewrite
2.内容管理系统(CMS)
tao02014 2007-07-27
  • 打赏
  • 举报
回复
用ie打开看源代码~
KingNE 2007-07-27
  • 打赏
  • 举报
回复
UP
kjah 2007-07-24
  • 打赏
  • 举报
回复
url rewrite
捏造的信仰 2007-07-24
  • 打赏
  • 举报
回复
将这个 jsp 部署起来,用浏览器打开这个 jsp 页面,然后在浏览器中查看页面源代码即可。

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧