社区
Web 开发
帖子详情
哪个有关于JSP生成静态页面的帮助文档及说明的电子书,秀出来,谢谢了
djpsunday
2004-08-24 11:34:37
我有个生成静态页面的模板,但不太会用,请大虾指点一二!
...全文
320
10
打赏
收藏
哪个有关于JSP生成静态页面的帮助文档及说明的电子书,秀出来,谢谢了
我有个生成静态页面的模板,但不太会用,请大虾指点一二!
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
10 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
ma
2004-11-12
打赏
举报
回复
不错,不错,受益匪浅呀。
dkmilk
2004-09-14
打赏
举报
回复
try {
URL url = new URL("http://www.sina.com");
URLConnection uc = url.openConnection();
InputStream is = uc.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(is));
while (br.ready()) {
str += br.readLine() + "\n";
}
is.close();
} catch (IOException e) {
e.printStackTrace();
}
pengpong
2004-08-25
打赏
举报
回复
up
djpsunday
2004-08-24
打赏
举报
回复
我不太会用的
zxjcool
2004-08-24
打赏
举报
回复
生成静态页面的模板,就是最好的例子
能给我发一份吗?
xianjun-2000@163.net
共同研究一下
一点晴
2004-08-24
打赏
举报
回复
都在这了,看懂了再修改自己用:
内容虽然不是太全,不过你应该能看懂是怎么回事。因为后台的JAVABEAN挺多,我只分了重要的出来,你改一下应该可以完成。
参考一下吧摸版是这样定义的:
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("操作失败!");
}%>
djpsunday
2004-08-24
打赏
举报
回复
没有人晓得么!不会吧!!
djpsunday
2004-08-24
打赏
举报
回复
什么意思的
dkmilk
2004-08-24
打赏
举报
回复
有两种方式,
一是用过滤器用setvlet实现
另外一种是用类url实现。
look4u
2004-08-24
打赏
举报
回复
GZ!!!!!
JSP
基础教程源代码
电子书
.word
本教程将深入探讨Java Server Pages(
JSP
)的基础知识,结合提供的
电子书
源代码,旨在帮助初学者快速掌握
JSP
的编程技巧和应用。
JSP
是Java平台上的动态网页技术,允许开发人员在HTML或XML文档中嵌入Java代码,从而...
计算机
电子书
全集1
jsp
1.
JSP
基础:
JSP
页面
由
静态
内容和动态元素组成,如指令(directives)、脚本元素(scriptlets)和表达式(expressions)。`
jsp
:include`、`
jsp
:forward`等动作标签用于
页面
的包含和转发。 2.
JSP
生命周期:包括加载...
JSP
程序设计从入门到精通355页.pdf
* 关于模板文本(
静态
HTML):模板文本是
JSP
页面
中的
静态
HTML 内容
JSP
基础学习
JSP
基础学习包括了变量、运算符、控制结构、函数、数组、对象等方面的内容。变量是
JSP
语言中的基本元素,用于存储和操作...
梁建武之第四章
JSP
语法
【
JSP
程序设计实用教程-第四章
JSP
语法详解】
JSP
(JavaServer Pages)是一种基于Java技术的动态网页开发工具,它结合了HTML和Java代码,使得开发者可以在
静态
页面
中嵌入动态功能。本章重点讲解
JSP
的基础语法,包括...
jsp
显示FlexPaper
通过
JSP
页面
,我们可以将
静态
的PDF文档转变为互动的在线阅读体验,使用户可以在任何支持Flash的设备上方便地浏览文档。不过,需要注意的是,由于现代浏览器逐渐弃用Flash,因此在实际应用中,你可能需要考虑使用其他...
Web 开发
81,122
社区成员
341,744
社区内容
发帖
与我相关
我的任务
Web 开发
Java Web 开发
复制链接
扫一扫
分享
社区描述
Java Web 开发
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章