icai项目开发日记(-)

本文介绍了使用Struts和Tiles实现网页布局的方法,包括配置Tiles插件、创建公用layout及定义tiles元素等步骤,旨在帮助读者理解如何通过Tiles实现网页模块的灵活组装。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  说来可笑,接到这个小项目的时候还不知道什么是icai.后来Google 了一下.ICAI--智能计算机辅助教育系统(Intelligent Computer Assisted Instruction 简称ICAI).这个项目凝聚了兴趣小组的心血.花了不少时间.现在终于成型.虽然有些功能不是很理想,但至少大家一直在努力.这个系统是学习大学本科教材<编译原理>(清华大学出版)后的我们兴趣小组的一次实践.功能主要包括:文法语言,词法分析,语法分析和中间代码生成的常规分析.偶主要负责web页面和web层的集成.在此记录一二,全当备忘.
  使用工具:eclipse+myeclipse+tomcat+sql server;
  使用框架:struts+log4+dbcp;

  一.使用tiles 

tiles的典型用法有两种.无论使用哪种方法.tiles是做为一个插件放入到struts应用中的.所以必须在struts-config.xml中插入这个插件通常的配置如下:

 

< plug-in  className ="org.apache.struts.tiles.TilesPlugin"   >
      
<!--  Path to XML definition file  -->
      
< set-property  property ="definitions-config"
                      value
="/WEB-INF/tiles-defs.xml"   />
      
<!--  Set Module-awareness to true  -->
      
< set-property  property ="moduleAware"  
                      value
="true"   />
</ plug-in >   

第一种用法是先创建一个公用layout.jsp页用来布局.然后在其中引用tiles-defs.xml文件中配置好的元素:
文件layout.jsp:

< table  width ="100%"   border ="0"  align ="center"  cellpadding ="0"  cellspacing ="0"  bgcolor ="white" >
  
< tr >
    
< td  width ="24%"  height ="10" >   </ td >
    
< td  width ="76%"  height ="10" >< tiles:insert  attribute ="header" /></ td >
  
</ tr >
  
< tr >
    
< td  width ="24%"  height ="100%"  align ="right"  valign ="top" >< tiles:insert  attribute ="sidebar" /></ td >
    
< td  width ="76%"  height ="100%"  align ="left" >< div  id ="body" >< tiles:insert  attribute ="content" />   </ div ></ td >
  
</ tr >
</ table >
< table  width ="100%"  border =0  align ="center"  cellPadding =0  cellSpacing =0  bgcolor ="WHITE"  margin-bottom =0 >
  
< tr >
    
< td  height ="64" >< tiles:insert  attribute ="footer" />   </ td >
  
</ tr >
</ table >

文件tiles-defs.xml就像一个零件装配的工厂,通过它可以组装各种网页,这对于见面风格的统一很是方便.重用的是它可以继承已有的组件以实现复用.

<? xml version="1.0" encoding="ISO-8859-1"  ?>

 
<! DOCTYPE tiles-definitions PUBLIC
       "-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN"
       "http://jakarta.apache.org/struts/dtds/tiles-config_1_1.dtd"
>

< tiles-definitions >
   
< definition   name ="sidebar-definition"    path ="/WEB-INF/tiles/common/sidebar-layout.jsp" >
      
< put  name ="bottom"  value ="/WEB-INF/tiles/common/sidebar-links.jsp" />
   
</ definition >   
   
< definition   name ="base-definition"   path ="/WEB-INF/tiles/common/layout.jsp" >
      
< put  name ="top-header"   value ="/WEB-INF/tiles/common/top-header.jsp" />
      
< put  name ="sidebar"  value ="sidebar-definition"  type ="definition" />
      
< put  name ="title"   value ="/WEB-INF/tiles/common/title.jsp" />
      
< put  name ="header"   value ="/WEB-INF/tiles/common/header.jsp" />
      
< put  name ="content"  value ="" />
      
< put  name ="footer"   value ="/WEB-INF/tiles/common/footer.jsp" />
   
</ definition >
<!--
    for defaul web
-->
   
< definition   name ="index-definition"    extends ="base-definition" >
      
< put  name ="content"  value ="/WEB-INF/tiles/default/Welcome.jsp" />    
   
</ definition >
</ tiles-definitions >


当然用tiles装订的网页是不能直接在地址栏中用localhost:8080/myapp/index-definition 访问的.

访问的方法是是struts-config.xml中设置<action-mapping>属性进行访问:

< action-mappings >
    
< action  path ="/index"   forward ="index-definition" />
</ action-mappings >


此时即可用http://localhost:8080/myapp/index.do 进行访问.

  第二种方法其实和第一种方法大同小异.思想是在每一个.jsp页面中布局装订各个元素.例如:
index.jsp

<% @ page contentType="text/html;charset=GB2312" %>
<% @ taglib prefix="html" uri="/WEB-INF/struts-html.tld" %>
<% @ taglib prefix="bean" uri="/WEB-INF/struts-bean.tld" %>
<% @ taglib prefix="tiles" uri="/WEB-INF/struts-tiles.tld" %>

< tiles:insert  page ="/tile/layout.jsp"  flush ="true" >
    
< tiles:put  name ="header"  value ="/tile/header.jsp" />
    
< tiles:put  name ="navigation"  value ="/tile/navigation.jsp" />
    
< tiles:put  name ="product"  value ="/tile/adminlogin.jsp" />
    
< tiles:put  name ="page"  value ="/tile/page.jsp"   />
    
< tiles:put  name ="footer"  value ="/tile/footer.jsp" />
</ tiles:insert >

它将用到layout.jsp这个文件:

< TABLE  width ="100%" border ="0"  align ="center"  cellpadding ="0"  cellspacing ="0"   >
            
< TR >
                
< TD  colspan ="3"  align ="center" >
                    
< tiles:insert  attribute ="header"   />
                
</ TD >
            
</ TR >
            
< TR >
                
< TD  colspan ="3"  align ="right" >
                    
< tiles:insert  attribute ="navigation"   />
                
</ TD >
            
</ TR >
            
< TR  height ="100%" >
                
< TD  width ="1%"  height ="1" ></ TD >
                
< TD  width ="99%"  align ="center" >
                    
< tiles:insert  attribute ="product"   />
                
</ TD >
                
< TD  width ="1%" ></ TD >
            
</ TR >
            
< TR >
                
< TD  width ="1%"  height ="1" ></ TD >
                
< TD  width ="99%"  align ="right" >
                    
< tiles:insert  attribute ="page"   />
                
</ TD >
                
< TD  width ="1%" ></ TD >
            
</ TR >
            
< TR >
                
< TD  colspan ="3"  align ="center" >
                    
< tiles:insert  attribute ="footer"   />
                
</ TD >
            
</ TR >
 
</ TABLE >

当然这时候就可以直接在地址栏中用http://localhost:8080/myapp/index.jsp 访问了.使用tiles的好处就是可以灵活的组装网页的各个模块.是实现复用的好工具.

  

内容概要:该研究通过在黑龙江省某示范村进行24小时实地测试,比较了燃煤炉具与自动/手动进料生物质炉具的污染物排放特征。结果显示,生物质炉具相比燃煤炉具显著降低了PM2.5、CO和SO2的排放(自动进料分别降低41.2%、54.3%、40.0%;手动进料降低35.3%、22.1%、20.0%),但NOx排放未降低甚至有所增加。研究还发现,经济性和便利性是影响生物质炉具推广的重要因素。该研究不仅提供了实际排放数据支持,还通过Python代码详细复现了排放特征比较、减排效果计算和结果可视化,进一步探讨了燃料性质、动态排放特征、碳平衡计算以及政策建议。 适合人群:从事环境科学研究的学者、政府环保部门工作人员、能源政策制定者、关注农村能源转型的社会人士。 使用场景及目标:①评估生物质炉具在农村地区的推广潜力;②为政策制定者提供科学依据,优化补贴政策;③帮助研究人员深入了解生物质炉具的排放特征和技术改进方向;④为企业研发更高效的生物质炉具提供参考。 其他说明:该研究通过大量数据分析和模拟,揭示了生物质炉具在实际应用中的优点和挑战,特别是NOx排放增加的问题。研究还提出了多项具体的技术改进方向和政策建议,如优化进料方式、提高热效率、建设本地颗粒厂等,为生物质炉具的广泛推广提供了可行路径。此外,研究还开发了一个智能政策建议生成系统,可以根据不同地区的特征定制化生成政策建议,为农村能源转型提供了有力支持。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值