周末了,写点开发经验大家分享
      废话少说,开门见山。静态页面生成技术是很多大网站采用的技术。用于大型网站的访问量特别高,采用动态页面难免服务器负担很重,负载大的时候可能down机。人们想出了采取以前的静态页面,这样可以减少服务器运算负载,但是一个一个页面的做肯定人工成本太高。于是乎就出现了静态页面生成技术。
      静态页面生成的实现方法大致可以分为两种
      一、模板生成
      实现思想:提前把网页的公共部分写好,做成一个模板,而不同的部分采用特殊字符代替。当需要生产的时候,用程序去读取模板,然后去数据库中找到需要的数据替换模板中的特殊字符。生成真正的网页然后存在网站的目录下。 

      有点:效率高,生成速度快。
      缺点:需要在网站建设之前就确定采用此方法生成。对于已建好的动态站点改版为此方法 工作量大。
      实例代码:
Article.Templete.txt

Asp.net 静态页面生成(1)----模板生成<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Asp.net 静态页面生成(1)----模板生成
<html xmlns="http://www.w3.org/1999/xhtml">
Asp.net 静态页面生成(1)----模板生成
<head>
Asp.net 静态页面生成(1)----模板生成    
<title><@Title@></title>
Asp.net 静态页面生成(1)----模板生成
</head>
Asp.net 静态页面生成(1)----模板生成
<body>
Asp.net 静态页面生成(1)----模板生成    
<table border="0" cellpadding="0" cellspacing="0" width="980">
Asp.net 静态页面生成(1)----模板生成        
<tr>
Asp.net 静态页面生成(1)----模板生成            
<td style="height: 200px">
Asp.net 静态页面生成(1)----模板生成                header
Asp.net 静态页面生成(1)----模板生成            
</td>
Asp.net 静态页面生成(1)----模板生成        
</tr>
Asp.net 静态页面生成(1)----模板生成        
<tr>
Asp.net 静态页面生成(1)----模板生成            
<td>
Asp.net 静态页面生成(1)----模板生成                
<table border="0" cellpadding="0" cellspacing="0" width="980">
Asp.net 静态页面生成(1)----模板生成                    
<tr>
Asp.net 静态页面生成(1)----模板生成                        
<td>
Asp.net 静态页面生成(1)----模板生成                        
<@Title@>
Asp.net 静态页面生成(1)----模板生成                        
</td>
Asp.net 静态页面生成(1)----模板生成                    
</tr>
Asp.net 静态页面生成(1)----模板生成                    
<tr>
Asp.net 静态页面生成(1)----模板生成                        
<td>
Asp.net 静态页面生成(1)----模板生成                        
<@Content@>
Asp.net 静态页面生成(1)----模板生成                        
</td>
Asp.net 静态页面生成(1)----模板生成                    
</tr>
Asp.net 静态页面生成(1)----模板生成                    
<tr>
Asp.net 静态页面生成(1)----模板生成                        
<td>
Asp.net 静态页面生成(1)----模板生成                        剪辑:
<@Editor@>&nbsp;&nbsp;&nbsp;&nbsp;访问次数:<@Hits@>
Asp.net 静态页面生成(1)----模板生成                        
</td>
Asp.net 静态页面生成(1)----模板生成                    
</tr>
Asp.net 静态页面生成(1)----模板生成                
</table>
Asp.net 静态页面生成(1)----模板生成            
</td>
Asp.net 静态页面生成(1)----模板生成        
</tr>
Asp.net 静态页面生成(1)----模板生成        
<tr>
Asp.net 静态页面生成(1)----模板生成            
<td style="height: 100px">
Asp.net 静态页面生成(1)----模板生成                footer
Asp.net 静态页面生成(1)----模板生成            
</td>
Asp.net 静态页面生成(1)----模板生成        
</tr>
Asp.net 静态页面生成(1)----模板生成    
</table>
Asp.net 静态页面生成(1)----模板生成
</body>
Asp.net 静态页面生成(1)----模板生成
</html>
Asp.net 静态页面生成(1)----模板生成


生成函数

相关文章:

  • 2021-12-30
  • 2021-12-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-01
  • 2022-01-15
  • 2022-03-08
猜你喜欢
  • 2021-05-18
  • 2021-09-17
  • 2022-12-23
相关资源
相似解决方案