最好给一个能使用的工具, 有比较详细的说明 , 可以短时间内上手使用!或者给出该实现的方法, 能有详细的文档最好.能给工具就给工具 , 实在没有就给个文档我试着做一下. 两个都给就更好了谢谢各位! 万分着急!
解决方案 »
- 求助!getHibernateTemplate.update()不起作用
- struts上传文件问题
- javaBean 配置问题。
- 图片插入数据库问题!!
- 关于<select></select>中的text和value在当前页的传值问题?
- 请问在jsp中下载文件时,如果文件太小的话(比如小于1k),那么就会出错,是怎么回事?
- 再次请教如何在ultra dev里连接数据库!
- 关于applet和servlet的问题,大家快帮我!!!
- 电商网站模板分模块可视化编辑该怎么做,求解
- jsp的网站如何使用html标签做联动下拉框(下拉框要有默认值),集合必需是从服务器段返回的
- 求达人帮忙解决按年月查询的问题
- servlet能否用类似post方法向其他JSP页面发出请求
怎么在读到循环等需要调用数据库的时候调用数据库内容并插入html中呢?
就是生成HTML文件吧? 没错,是要生成html文件,为了加快速度, 有资料么?谢谢,请帮忙
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>生成静态文件</title>
<link href="../css/style.css" rel="stylesheet" type="text/css"/>
<script language=vbscript>
Function bytes2BSTR(vIn)
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn, i, 1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn, i + 1, 1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
End Function
</script>
<script language=javascript>
function sendMsg(url){
var oSend = new ActiveXObject("Microsoft.XMLHTTP");
var sS="aa=1";
oSend.open("POST",url,false);
oSend.setRequestHeader("Content-Length",sS.length);
oSend.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded");
oSend.send(sS);
var oDom = new ActiveXObject("Microsoft.XMLDOM");
oDom.async = false;
body='<\%@ page contentType="text/html; charset=GBK" language="java" \%>';
body = body+bytes2BSTR(oSend.responseBody);
//body = body+oSend.responseBody;
//alert(body);
document.form1.txtA.value=body;
}
</script>
</head><body onload=sendMsg("url")><!-- 要生成静态页的动态页url -->
<form name=form1 method=post>
<div align="center"> </div>
<div align="center">
<table class=tableBorder cellspacing=1 cellpadding=3 align=center border=0>
<tbody>
<tr align="left">
<th height="20" background="images/admin_bg_1.gif" class=tableHeaderText>
<div class="style5">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><span class="style6"> </span></td>
<td align="right"> </td>
</tr>
</table>
</div>
</th>
</tr>
<tr>
<th bgcolor="#E4EDF9" class=tableHeaderText style3>
<div align="left">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="24" width="15%" align="center">内容:<br>
</td>
<td height="24" width="85%"><b>
<textarea name="txtA" cols="80" rows="30" readonly></textarea>
</b></td>
</tr>
</table>
</div>
<div align="left"><span class="text"> </span> <span class="text"> </span>
</div>
<div align="left"> <span class="text"> </span> </div>
</th>
</tr>
<tr align="right">
<th bgcolor="#F1F3F5" class=tableHeaderText style2 align="center"> <span class="forumrow">
<INPUT type=submit value=确定 name=Submit310322>
<input type=reset value=取消 name=Submit310222>
</span></th>
</tr>
<tr>
<th bgcolor="#E4EDF9" class=tableHeaderText style3>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr align="center">
<td height="24" width="15%"><br>
</td>
<td height="24" width="85%"><b></b></td>
</tr>
</table>
</th>
</tr>
</tbody>
</table>
<br>
<p> </p>
</div>
<p align="center" class="style4"></p>
<span class="forumrow"></span>
</form>
</body>
</html>
<%
String txtA=request.getParameter("txtA");
com.xxx.StringHandle handle = new com.xxx.StringHandle();
if(txtA!=null){
String path=getServletContext().getRealPath("/");
path=path+"/index.htm";//要生成的静态页
FileWriter writer= new FileWriter(path);
writer.write(txtA);
writer.close();
out.println(handle.getJsAlert("首页生成成功!!!",""));
}
%>
老兄, 兄弟我正着急呢,别开玩笑好不好.真心帮我就给点象样的办法, 谢了
http://www.diaor.com/blog/article.asp?id=53我指可以不必整体生成htm,可以局部做。比如index.htm可以拆分成header.htm,footer.htm,其它更新.htm...就像搭积木,维护也比较容易。只是index.htm换成index.shtml至于如何在服务器端生成一个文件,这个例子太多了,网上搜一下。算了,还是贴点代码给你吧。
//...................................
import java.io.File;
import java.io.FileOutputStream;
//...................................
file = new File("D:\index.htm");
FileOutputStream fout = new FileOutputStream(file);
fout.write(b);
fout.close();
//...................................
兄弟,多谢了,我试试看.
/*
* Created on 2006-3-4
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package com.easydone.cn.tools.utils;import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Date;/**
* @author Administrator
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class MakeHtml {
private static long star = 0;
private static long end = 0;
private static long ttime = 0;
//返回html代码
public static String getHtmlCode(String httpUrl){
Date before = new Date();
star = before.getTime();
String htmlCode = "";
try {
InputStream in;
URL url = new java.net.URL(httpUrl);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection = (HttpURLConnection) url.openConnection();
connection.setRequestProperty("User-Agent","Mozilla/4.0");
connection.connect();
in = connection.getInputStream();
java.io.BufferedReader breader = new BufferedReader(new InputStreamReader(in , "GBK"));
String currentLine;
while((currentLine=breader.readLine())!=null){
htmlCode+=currentLine;
}
} catch (Exception e) {
e.printStackTrace();
}finally{
Date after = new Date();
end = after.getTime();
ttime = end-star ;
System.out.println("执行时间:"+ttime +"秒");
}
return htmlCode;
}
//存储文件
public static synchronized void writeHtml(String filePath,String info,String flag) {
PrintWriter pw = null;
try {
File writeFile = new File(filePath);
boolean isExit = writeFile.exists();
if (isExit != true) {
writeFile.createNewFile();
} else {
if (!flag.equals("NO")) {
writeFile.delete();
writeFile.createNewFile();
}
}
pw = new PrintWriter(new FileOutputStream(filePath, true));
pw.println(info);
pw.close();
} catch (Exception ex) {
System.out.println(ex.getMessage());
}finally{
pw.close();
}
}
public static void main(String[] args) {
String url = "http://www.easydone.cn/index.htm";
writeHtml("c:/demo.htm",getHtmlCode(url),"NO");
}
}