请高手进来谈谈关于页面静态化技术,在线等待 。。。 请高手进来谈谈关于页面静态化技术,在线等待 小弟完全没做过 只想听听大家的意见注意是真静态 不是URL改变 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 好像不同的语言有不同的方式吧,比如:JSP不需要了吧;PHP的smarty应该算吧 静态还真是麻烦,以前只做过根据模板替换文本,生成静态html文件的。至于列表显示的东西可没弄过,很久没涉及这方面了 可以去我的博客看一下,http://blog.ganhui0818.cn/article/jsp/8.htm这篇文章也是转了别人的。我之前做过静态化,是管理员在后台生成相关的静态页面。现在贴出来供参考,请高手指教。action中package action;import java.util.ArrayList;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import model.MakeHtml;import model.ProductManager;import model.Sort;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionForward;import org.apache.struts.action.ActionMapping;import org.apache.struts.actions.DispatchAction;public class MakeHtmlAction extends DispatchAction { //生成首页商品推荐 public ActionForward tuijianHtml(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // TODO Auto-generated method stub String url=request.getRealPath("/"); String path=request.getContextPath(); System.out.println("url:"+url); ArrayList arr=ProductManager.tuijianProduct(); MakeHtml.tuijianHtml(arr,url,path); return mapping.findForward("toTuijian"); } }业务逻辑处理:public class MakeHtml { public static void tuijianHtml(ArrayList arr,String url,String path){ System.out.println("url--:"+url); File f=new File(url+"style\\html\\tuijian.html"); if(!f.exists()){ try { f.createNewFile(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }else{ f.delete(); try { f.createNewFile(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } // System.out.println("ffff"+f.getParent()+"8888"+f.getPath()); try { FileOutputStream fos=new FileOutputStream(f); PrintStream p=new PrintStream(fos); p.print("<table class=\"table\">"); for(int i=0;i<arr.size();i++){ if(i%2==0||i==0){ p.print("<tr>"); } p.print("<td width=\"250\" style=\"font-size: 12px\">"); ProductInfo product=(ProductInfo)arr.get(i); p.print(product.getName()+"<br>"); p.print("<img src=\""+path+"/upload/"+product.getImage()+"\""+" width=\"120\" height=\"120\"/><br>"); p.print(product.getDescript()+"<br>"); p.print("<div style=\"text-decoration: line-through\">市场价:"+product.getPrice()+"</div>"); p.print("会员价:"+product.getSaleprice()+"<br>"); p.print("<a href=\""+path+"/detail.jsp?id="+product.getId()+"\">详情</a>  "); p.print("<a href=\""+path+"/order.do?method=order&id="+product.getId()+"\">定购</a></br>"); p.print("</td>"); if((i+1)%2==0){ p.print("<tr><td colspan=\"2\"><hr><td></tr></tr>"); } } p.print("</table>"); p.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } }}仅供参考。。 静态化的话大概就是生成html页面,要求生成复杂的html页面的话,用cms就行,生成简单的用freemaker自己生成 静态化的话大概就是生成html页面,要求生成复杂的html页面的话,用cms就行,生成简单的用freemaker自己生成 静态化的话大概就是生成html页面,要求生成复杂的html页面的话,用cms就行,生成简单的用freemaker自己生成 求此段JS语句的说明 jsp与数据库连接问题 问个spring的初级问题 一个初学WEB开发者的烦恼 为什么转到jsp文件变成下载jsp文件了? 各位帮忙看个简单的问题吧。。。我的情况有点特殊。。。 谁可以教我eclipse?| 【resin下的web.xml应该怎么写?一个简单得servlet】 各位高手请指点一下,怎样使用连接池(急) 为什么我用servlet处理表单的时候,出现这样的错误? FreeMarker问题 请大家帮帮忙 struts2配置问题
比如:JSP不需要了吧;PHP的smarty应该算吧
action中package action;import java.util.ArrayList;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import model.MakeHtml;
import model.ProductManager;
import model.Sort;import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;public class MakeHtmlAction extends DispatchAction { //生成首页商品推荐
public ActionForward tuijianHtml(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
// TODO Auto-generated method stub
String url=request.getRealPath("/");
String path=request.getContextPath();
System.out.println("url:"+url);
ArrayList arr=ProductManager.tuijianProduct();
MakeHtml.tuijianHtml(arr,url,path);
return mapping.findForward("toTuijian");
}
}业务逻辑处理:
public class MakeHtml {
public static void tuijianHtml(ArrayList arr,String url,String path){
System.out.println("url--:"+url);
File f=new File(url+"style\\html\\tuijian.html");
if(!f.exists()){
try {
f.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}else{
f.delete();
try {
f.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
// System.out.println("ffff"+f.getParent()+"8888"+f.getPath());
try {
FileOutputStream fos=new FileOutputStream(f);
PrintStream p=new PrintStream(fos);
p.print("<table class=\"table\">");
for(int i=0;i<arr.size();i++){
if(i%2==0||i==0){
p.print("<tr>");
}
p.print("<td width=\"250\" style=\"font-size: 12px\">");
ProductInfo product=(ProductInfo)arr.get(i);
p.print(product.getName()+"<br>");
p.print("<img src=\""+path+"/upload/"+product.getImage()+"\""+" width=\"120\" height=\"120\"/><br>");
p.print(product.getDescript()+"<br>");
p.print("<div style=\"text-decoration: line-through\">市场价:"+product.getPrice()+"</div>");
p.print("会员价:"+product.getSaleprice()+"<br>");
p.print("<a href=\""+path+"/detail.jsp?id="+product.getId()+"\">详情</a>  ");
p.print("<a href=\""+path+"/order.do?method=order&id="+product.getId()+"\">定购</a></br>");
p.print("</td>");
if((i+1)%2==0){
p.print("<tr><td colspan=\"2\"><hr><td></tr></tr>");
}
}
p.print("</table>");
p.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}仅供参考。。