页面静态化
来源:互联网 发布:mac电磁阀型号 编辑:程序博客网 时间:2024/06/05 06:06
网站提高性能的方案有很多,网站架构方面考虑,最初的性能优化可以考虑提高单台服务器的配置。把数据库和代码分别部署在两台服务器,页面缓存,数据缓存,静态化,分布式,代码读写分离,负载均衡。这些东西都是大型网站发展所必须经历的升级过程,前两种方案非常容易实现,页面缓存J2EE中用的不多,数据缓存可以借助hibernate提供的第三方支持,分布式和读写分离,我的方案是使用EJB3,均衡负载可由Apache+Tomcat提供,本文简单说一下页面静态化技术,
也就是jsp通过html模板生成html页面,比较高级点的处理就是让它自动静态化,其实无论使用什么框架原理都是相通的。在这我提供一个纯java静态化的类,希望对大家有所帮助!
public static void convertHtml(String sUrl, String charset, String sSavePath, String sHtmlFile) throws IOException { int HttpResult; URL url = new URL(sUrl); URLConnection urlconn = url.openConnection(); urlconn.connect(); HttpURLConnection httpconn = (HttpURLConnection) urlconn; HttpResult = httpconn.getResponseCode(); if (HttpResult != HttpURLConnection.HTTP_OK) { } else { InputStreamReader isr = new InputStreamReader( httpconn.getInputStream(), charset); BufferedReader in = new BufferedReader(isr); String inputLine; if (!sSavePath.endsWith("/")) { sSavePath += "/"; } FileOutputStream fout = new FileOutputStream(sSavePath + sHtmlFile); while ((inputLine = in.readLine()) != null) { System.out.println(inputLine); fout.write((inputLine + "/n").getBytes()); } in.close(); fout.close(); } } public static void main(String[] args) throws IOException { StaticTest ru = new StaticTest(); String filePath = ru.getClass().getResource(".").getPath().toString(); // 取得项目根目录 convertHtml("http://zl.aisky.net", "UTF-8", filePath + "/", "index.html"); }
0 0
- 页面静态化【伪静态】
- php 静态化页面 生成静态页面
- 动态页面静态化
- 动态页面静态化
- jsp页面静态化
- freemark页面静态化
- 页面静态化
- 动态页面静态化
- freemarker页面静态化
- JSP页面静态化
- 动态页面静态化
- 页面静态化--总结
- jsp页面静态化
- l静态化页面
- php页面静态化
- 页面静态化
- aspx页面静态化
- PHP页面静态化
- C6-1 最大子数组和
- hdu 1114 Piggy-Bank(完全背包)
- Mysql SQL查询今天、昨天、n天内、第n天
- 文件超过某个大小就删除(C语言)
- 关于UIScrollView的一点小发现
- 页面静态化
- 【LeetCode】51. N-Queens
- 图片自适应父元素的大小,并左右上下居中
- C++文件写入
- Mysql 字符串函数汇总
- gradle基础讲解系列1
- django学习10 数据库 增删改查 简单方法
- LiteOS学习第七篇——系统滴答
- android 编译错误 Error:(1, 0) Plugin with id 'com.android.application' not found. 解决