社区
Web 开发
帖子详情
自动生成HTML
cocohui
2004-08-27 05:42:41
希望大家讨论自动生成HTML 的代码问题的看法
...全文
397
16
打赏
收藏
自动生成HTML
希望大家讨论自动生成HTML 的代码问题的看法
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
16 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
bozy
2004-09-06
打赏
举报
回复
都是通过文件处理对象,
比方asp中用的是FileSystemObject
jsp中用的是FileOutputStream
要仔细学习才行。
cocohui
2004-09-06
打赏
举报
回复
我看真的没有知道了吗???
在江湖中,传说有一个高手,他无所不知无所不能。。他怎么没有出现在 www.csdn.net
了。。郁闷!
mygia
2004-09-06
打赏
举报
回复
好。我也收藏!
xiangbo520
2004-09-04
打赏
举报
回复
好啊!收藏
cocohui
2004-09-04
打赏
举报
回复
我用了之后怎么没有结果啊。。
能不能在详细一点的列子
chinawit
2004-08-28
打赏
举报
回复
不错!ding
maoerzuozuo
2004-08-28
打赏
举报
回复
mark
CNetol
2004-08-28
打赏
举报
回复
学习~!!!!!
一点晴
2004-08-28
打赏
举报
回复
都在这了,看懂了再修改自己用:
JSP直接生成HTML文件
参考一下吧摸版是这样定义的:
news.template
<html>
<head>
<title>Untitled Document</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$> 发布时间:<font color=#ff0000><$date$></font></td>
</tr>
<tr>
<td><$content$>
</td>
</tr>
</table>
</body>
</html>
一个生成HTML的类:
import java.io.*;
public class WriteHtml
{
public WriteHtml()
{
}
public static void save(String s, String s1, String s2)
throws WriteFileException
{
try
{
a(s1);
FileOutputStream fileoutputstream = new FileOutputStream(s1 + s2);
byte abyte0[] = s.getBytes();
fileoutputstream.write(abyte0);
fileoutputstream.close();
}
catch(IOException ioexception)
{
throw new WriteFileException();
}
}
private static void a(String s)
{
File file = new File(s);
if(!file.exists())
file.mkdirs();
}
}
一个读取摸版的类:
import java.io.*;
public class ReadTemplates
{
private static String _fldif = null;
private static Object a = new Object();
public ReadTemplates()
{
}
public static String getTlpContent(String s)
throws ReadTemplateException
{
if(_fldif == null)
synchronized(a)
{
if(_fldif == null)
try
{
System.out.println("+++++++++++++");
_fldif = a(s);
}
catch(ReadTemplateException readtemplateexception)
{
throw new ReadTemplateException("模板信息读取失败。");
}
}
return _fldif;
}
private static synchronized String a(String s)
throws ReadTemplateException
{
String s1 = null;
try
{
FileInputStream fileinputstream = new FileInputStream(s);
int i = fileinputstream.available();
byte abyte0[] = new byte[i];
fileinputstream.read(abyte0);
fileinputstream.close();
s1 = new String(abyte0);
}
catch(IOException ioexception)
{
throw new ReadTemplateException();
}
return s1;
}
}
jsp文件:
<%@ page contentType="text/html; charset=gb2312"%>
<%@ include file="/inc.jsp"%>
<%
String[] flag = {"<$title$>","<$date$>","<$author$>","<$content$>"};
String title=request.getParameter("title");
String content=request.getParameter("content");
String editer="admin";
//Session.getAttribute("s_userName");
int classid=Integer.parseInt(request.getParameter("class"));
String filePath = "";
filePath = application.getRealPath("./adminroot/news.template");
String templateContent;
try{
templateContent = ReadTemplates.getTlpContent(filePath);
}catch(ReadTemplateException e){
throw new Exception("模板信息读取失败。请联系系统管理员。");
}
templateContent = ReplaceAll.replace(templateContent,flag[0],title);
templateContent = ReplaceAll.replace(templateContent,flag[1],GetDate.getStringDate());
templateContent = ReplaceAll.replace(templateContent,flag[2],editer);
templateContent = ReplaceAll.replace(templateContent,flag[3],content);
// 根据时间得文件名与路径名
Calendar calendar = Calendar.getInstance();
String fileName = String.valueOf(calendar.getTimeInMillis()) +".shtml";
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("操作失败!");
}%>
zzzxxxcccvvv
2004-08-28
打赏
举报
回复
up
cocohui
2004-08-28
打赏
举报
回复
我看过ASP有自动生成HTML的文件的代码。。不知道JSP的代码是否跟ASP相似。。
有谁写过提供一个具体的代码看看。。本人不胜感激!
pleonheart
2004-08-27
打赏
举报
回复
楼上,应该是xml+xsl/xslt
shsoftfirst
2004-08-27
打赏
举报
回复
xml+xls
constantine
2004-08-27
打赏
举报
回复
up
life8love
2004-08-27
打赏
举报
回复
自动生成html没有听说过。楼上的说法,顶。。
mbl
2004-08-27
打赏
举报
回复
没有!自己好好学。用DREAMWEAVER也不错
雷の龙邮件列表
1.基于国际流行的jmail4.0以及以上版本 ...8.订阅代码的
自动生成
9.生成的代码支持远程调用。就是说你可以把邮件列表程序放在一个程序里然后在另外一个服务器的页面上调用订阅程序,而不用修改生成的代码
Flying-Saucer jar包
这样,当Web应用运行时,容器(如Tomcat或Jetty)能够自动加载这些库,以便于Flying-Saucer库正常工作。 使用Flying-Saucer进行
HTML
到PDF转换的基本流程如下: 1. 创建一个`ITextRenderer`实例,它是Flying-Saucer...
富翁工作室多用户搜索引擎
7、常用关键词页面
自动生成
,用户输入查找的关键词都保存在数据库中,如果有相同的关键词则这些关键词数量累加,管理员管理的时候可以生成排名在头几位的关键词页面,也就是提前替用户把这些关键词提前搜索出来了,...
前端拖拽
自动生成
html
的框架_用深度学习
自动生成
HTML
代码
用深度学习
自动生成
HTML
代码选自Floydhub作者:Emil Wallner机器之心编译如何用前端页面原型生成对应的代码一直是我们关注的问题,本文作者根据 pix2code 等论文构建了一个强大的前端代码生成模型,并详细解释了如何...
Sublime中
自动生成
HTML
框架
二、若tab键失效无法
自动生成
HTML
框架,可尝试一下方法: 1、安装package control 使用Ctrl+Shift+P打开命令行,输入install 选择install package 回车,等待,然后查看Preferences下面会出现Package setting和...
Web 开发
81,122
社区成员
341,744
社区内容
发帖
与我相关
我的任务
Web 开发
Java Web 开发
复制链接
扫一扫
分享
社区描述
Java Web 开发
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章