生成静态页面技术,现在有两种解决方案(我了解得)
一种是在取数据时候,建立写入流,把动态生成得数据写入预先设置好的html文件里面
例子:http://hi.baidu.com/fei112/blog/item/92f4112e5c2a5d544fc22659.html
二是用freeer这个java开源模板,建议楼主去google下,这个得需要学习下
一种是在取数据时候,建立写入流,把动态生成得数据写入预先设置好的html文件里面
例子:http://hi.baidu.com/fei112/blog/item/92f4112e5c2a5d544fc22659.html
二是用freeer这个java开源模板,建议楼主去google下,这个得需要学习下
解决方案 »
- 问一个访问地址如何根据参数动态进入方法
- web service 返回中文字符出错! 高分求解
- tomcat启动错误,搞不清怎么回事?配了struts2,hibernate
- 请教关于用middlegen生成部分库表的映射文件的问题?
- 用JS如何限制上传文件格式
- 谁能告诉struts的mappings forward与http-url,jsp response redirect连接在原理有什么区别?
- 急!!高分请教applet调用EJB的问题?解决了问题可以再给分!
- jbuilder9 中自带的例子,Esite (for weblogic) 运行时候出错:javax.naming.NameNotFoundException: Unable to resolve 'Cart' Resolved ;
- JDBC连接SQL server 2000用什么方法??up有分~~~~~
- spring利用注解@Value获取properties属性为null, 求解~
- 急需解决!!!!!谢谢
- hibernate按条件查询
<%@ page contentType="text/html; charset=utf-8" language="java" pageEncoding="utf-8" %>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="http://localhost:8080/vi/jsp/viiee_manage/css/style.css"/>
<script language="javascript" src="http://localhost:8080/vi/js/Base.js"></script>
<script language="javascript" src="http://localhost:8080/vi/js/FormUtil.js"></script>
<script type="text/javascript" src="http://localhost:8080/vi/FCKeditor/fckeditor.js"></script>
<title>静态包含文件</title>
</head>
<body>
<html:form action="/ajax/saveAjaxHtml.htm" method="post">
<TABLE width="100%" border="0" cellspacing="1" cellpadding="3" align=center class="tableBorder">
<tr><th height=25 colspan="2" class="tableHeaderText">添加文件</th></tr><TR ALIGN="center"><TD>
</TD></TR>
<TR ALIGN="center">
<tr><td>标题:<input type=text id="name" name="name"/><font color='#FF0000'>*</font></td></tr>
<tr><td>序号:<input type=text id="sort" name="sort"/></td></tr>
<TR><td><input type="radio" name="flag" id="flag1" value="0" onClick=showUrl()>正文生成<input type="radio" name="flag" id="flag2" value="1" onClick=showContent()>从url生成</td></TR>
<tr><td id="style1" style="DISPLAY: none">正文:<textarea name="content" id='content' rows="10" cols="50"></textarea></td></tr>
<script type="text/javascript">
var oFCKeditor=new FCKeditor('content');
oFCKeditor.ReplaceTextarea();
</script>
<tr><td id="style2" style="DISPLAY: none">请求的url地址:<input type="text" name="fromurl" id="fromurl"><font color='#FF0000'>*</font></td></tr>
<tr><td>生成静态文件的位置:<input type="text" name="topath" id="topath"><font color='#FF0000'>*</font></td></tr>
<tr><td>请求密钥:<input type="text" name="key" id="key"></td></tr>
<tr><td><input type="submit" name="submit" value="添加" onClick="return check()"></input>
<input type="reset" name="reset" value="重置"></input></td></tr>
</tr>
</TABLE>
</html:form>
</body>
</html>
<script LANGUAGE="JavaScript">
function showUrl(){
if (document.ajaxHtmlForm.flag1.checked == true) {
style1.style.display = "";
style2.style.display = "none";
}else{
style1.style.display = "none";
style2.style.display = "";
}
}
function showContent(){
if (document.ajaxHtmlForm.flag2.checked == true) {
style2.style.display = "";
style1.style.display = "none";
}else{
style2.style.display = "none";
style1.style.display = "";
}
}
</script>
<script LANGUAGE="JavaScript">
function check()
{
var name =gid("name");
var sort =gid("sort");
var topath =gid("topath");
var key =gid("key");
if (trim(name.value)=="")
{
alert("请输入标题!")
name.focus()
name.select()
return false;
}
if (trim(sort.value)=="")
{
alert("请输入序号!")
sort.focus()
sort.select()
return false;
}
if (trim(topath.value)=="")
{
alert("请输入生成静态文件的位置!")
topath.focus()
topath.select()
return false;
}
}
function trim(inputString) {
if (typeof inputString != "string") { return inputString; }
var retValue = inputString;
var ch = retValue.substring(0, 1);
while (ch == " ") {
//检查字符串开始部分的空格
retValue = retValue.substring(1, retValue.length);
ch = retValue.substring(0, 1);
}
ch = retValue.substring(retValue.length-1, retValue.length);
while (ch == " ") {
//检查字符串结束部分的空�g e格
retValue = retValue.substring(0, retValue.length-1);
ch = retValue.substring(retValue.length-1, retValue.length);
}
while (retValue.indexOf(" ") != -1) {
//将文字中间多个相连的空格变为一个空�格
retValue = retValue.substring(0, retValue.indexOf(" ")) + retValue.substring(retValue.indexOf(" ")+1,retValue.length);
}
return retValue;
}
</script>
public ActionForward saveAjaxHtml(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response) {
if (!checkLogin(request)) return mapping.findForward("adminlogin");
AjaxHtmlForm ajaxHtmlForm =(AjaxHtmlForm)form;
AjaxHtml ajaxHtml=new AjaxHtml();
ajaxHtml.setCatid(ajaxHtmlForm.getCatid());
ajaxHtml.setFlag(ajaxHtmlForm.getFlag());
ajaxHtml.setSort(ajaxHtmlForm.getSort());
ajaxHtml.setName(ajaxHtmlForm.getName());
ajaxHtml.setFromurl(ajaxHtmlForm.getFromurl());
ajaxHtml.setTopath(ajaxHtmlForm.getTopath());
ajaxHtml.setContent(ajaxHtmlForm.getContent());
ajaxHtml.setKey(ajaxHtmlForm.getKey());
try {
getServices().getAjaxHtmlService().saveAjaxHtml(ajaxHtml);
} catch (Exception e) {
e.printStackTrace();
}
return mapping.findForward("success");
}
可以用urlrewrite掩饰
http://tuckey.org/urlrewrite/
这是两种生成静态页面的技术实现。用freeer更好一些,通过预置模板生成。但是还会有很多其他的问题,比如怎样解决静态页生成的时机问题,如果几分钟一次也不好,长时间了也不好。
还有怎样解决静态页的动态交互问题,一交互就重新生成,还是制定其他的策略就生成呢,用什么交互呢,交互后用户怎样能第一时间感知,但又不消耗服务器资源呢。
好多问题,需要思考啊。