81,091
社区成员
发帖
与我相关
我的任务
分享
public static String Jsp2Html(){
File f=new File("你要存放文件的路径");
StringBuffer sb=new StringBuffer();//这里放的是你页面里的所有内容
//如果调用数据库的话,把从数据里得到的内容也写到时面,
Info_db idb=new Info_db();//一个数据库类,只是给你一个例子,
String name=idb.getName();
sb.append("<html>");
sb.append("\n<head>");
sb.append("\n<title>我的页面</title>");
sb.append("\n</head>");
sb.append("\n<body>");
sb.append("\n 这里是从数据库里取的数据"+name);
sb.append("\n<body>");
sb.append("\n</html>");
try {
FileOutputStream os = new FileOutputStream(f.toString(), false);
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(os,
"gbk"));
out.write(sb.toString());
out.close();
}
catch (IOException e) {
e.printStackTrace();
}
}