Bruce
IQ == GO ANYWHERE.DO ANYTHING!
posts - 4,comments - 2,trackbacks - 0

前段时间一直在忙一个项目,是基于数据交换平台的一个业务查询分析系统,由于是政府的项目,就不再详细说明啦,主要用的技术就是struts+ibatis+jstl,其实说技术嘛根本就谈不上啦,呵呵,由于是第一次用IBATIS,所以啦花啦几天去学习IBATIS,个人感觉,iBATIS相对于hibernate而言,自由度要大些,由于很多运算都是在SQL语句中完成的,所以我们这个项目的持久层没有用HIBERNATE,恩,现在吃饭时间到啦!下午再继续写啦!!(未完)
   继续------
   今天没什么事情,就想着先来把这篇 文章先给写完,呵呵,SPRING嘛,下午再搞啦!
下面的是sql-map-config.xml文件,我给贴出来吧,大家也看看!
<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE sqlMapConfig PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
    "http://ibatis.apache.org/dtd/sql-map-config-2.dtd">

<sqlMapConfig>

<!-- 这个就是数据库的联接啦,如果加入了SPRING的话,就全部交由SPRING来管理啦--> 
<properties resource="com/netmarch/sjjh2/maps/database.properties"/>
  <settings
 cacheModelsEnabled="true"
 enhancementEnabled="true"
 lazyLoadingEnabled="true"
 maxRequests="32"
 maxSessions="10"
 maxTransactions="5"
 useStatementNamespaces="false"
  />
<!-- 下面这些不说大家也能看懂啦-->
  <typeAlias alias="order" type="testdomain.Order"/>
  <transactionManager type="JDBC">
    <dataSource type="SIMPLE">
      <property name="JDBC.Driver" value="${driver}"/>
   <property name="JDBC.ConnectionURL" value="${url}"/>
   <property name="JDBC.Username" value="${username}"/>
   <property name="JDBC.Password" value="${password}"/>
      <property name="JDBC.DefaultAutoCommit" value="true" />
   <property name="Pool.MaximumActiveConnections" value="10"/>
      <property name="Pool.MaximumIdleConnections" value="5"/>
   <property name="Pool.MaximumCheckoutTime" value="120000"/>
   <property name="Pool.TimeToWait" value="500"/>
   <property name="Pool.PingQuery" value="select 1 from ACCOUNT"/>
   <property name="Pool.PingEnabled" value="false"/>
   <property name="Pool.PingConnectionsOlderThan" value="1"/>
   <property name="Pool.PingConnectionsNotUsedFor" value="1"/>
    </dataSource>
  </transactionManager>

<!-- 这里要对应好哦,呵呵, 这里可是执行数据库操作的配置文件哦,--> 
<sqlMap resource="com/netmarch/sjjh2/maps/Rs.xml" />
  <sqlMap resource="com/netmarch/sjjh2/maps/Mz.xml" />
   <sqlMap resource="com/netmarch/sjjh2/maps/HuiZong.xml" />
 
</sqlMapConfig>
下面的database.properties就是上面所对应的
<properties resource="com/netmarch/sjjh2/maps/database.properties"/>


driver=oracle.jdbc.driver.OracleDriver
url=jdbc:oracle:thin:@192.168.1.110:1521:center
username=XXX
password=XXX

   先写到这,事情又来啦!有空再接着写!
好,下面我们接着再来写!
刚才我上来一看就有一位朋友说有源码和UML图就好啦,好吧,我就先把UML类图给弄上来!各位稍等,上传中。。。。。
相关的部分类图在我的相册里面!我时间不多(我不知道这里是咱转图片到这里面的),大家将就着看吧!

posted @ 2006-09-26 12:01 Bruce 阅读(1000) | 评论 (2)编辑 收藏

logic:Iterator 标签(以下简称 该标签 )是 Struts 里非常常用的一个标签,其作用在于循环显示给定容器对象中的值。
  
  如此常用的标签,其源代码当然需要拿出来研究一下,以下列举几条研究成果:
  
   1 、该标签内部使用 Collection 来表示给定的容器,所有的给定容器对象(如 ArrayList Map 等)都会被其转化成为 Collection,Collection 实际就是 Map List 的父类
  
   2 、该标签自己维护循环索引,不用程序员管理索引
  
   3 、该标签常见的几个属性如下: name property scope id
  
  对应 Struts 给出的 Api 说明如下:
  
   name: 包括要遍历 Collection Jsp 页面的 bean 的名字(如果 property 没有被定义),或者是那些通过 getter 方法获得属性的 Jsp 中的 Bean 的名字,这些 getter 方法返回的是 Collection (如果 property 定义了)。
  
   property: name 命名的 Jsp bean 中定义的属性的名字,通过 getter 方法返回一个 Collection
  
   scope: 指示到哪里去寻找 name 为名字的 bean ,如果没有定义缺省为 "any scope"
  
   id: 如果 Collection 非空的话,在每次遍历时候 Collection 中每个元素的名字。
  
  其中除了 id 每个元素均为 Rt expr ,这儿的 rt expr 的意思就是 Run Time Expression 。明确的说就是,如果你对一个 Attribute <rtexprvalue> 指定为 true ,你就可以在这样的属性中使用 <%=%> 之类的东东。这个配置文件在 tld 中。
  
  只有 id 是必须要说明的。
  
  关于 Api 说明的说明:
  
   id 只是一个临时标识,在下面的 <bean:write 里面出现的 name 属性要和 id 一致才能打印出 <bean:write property ,而此 property 就是在 iterator 中的属性。
  
  举例说明
  
  以下代码生成一个阶梯状表格
  
  系统 资源 操作
  
   soft3
   res3
   opt3
   soft12
   res12
   opt1211
   soft11
   res11
   opt1111
  
  在此之前传来一个 request.getAttribute("userPurview") ,所以有在第一个 logic 中的 userPurview, 就是在这个 request 里面寻找 userPurview
  
  返回的是一个 list
  
   <table width="300" border="0">
   <tr><td> 系统 </td>
   <td> 资源 </td>
   <td> 操作 </td>
   </tr>

<!--- 第一级迭代 -->

//request 中的数值为” userPurview ”作用范围在 request , 取的 ID 名为 targetSys
   <logic:iterate id="targetSys" name="userPurview" scope="request">   // 这个 id 可以随便起名,但是要注意下文使用的一致性
   <tr bgcolor="#cccccc"><td height="21" class="unnamed2">
   <bean:write name="targetSys" property="cn"/>      // 此处 name 和上面 id 保持一致, property 就是第一个 list 里面的元素
   </td>
   <td height="21" class="unnamed2"> </td>
   <td height="21" class="unnamed3"> </td>
   </tr>

<!--- 第二级迭代 -->


   <logic:iterate id="targetRes" name="targetSys" property="purviewResList">
   <tr><td height="21" class="unnamed2"> </td><td   height="21" class="unnamed5">
   <bean:write name="targetRes" property="cn"/>
   </td>
   <td   height="21" class="unnamed6"> </td>
   </tr>
   <!--- 第三级迭代 -->


   <logic:iterate id="targetOpr" name="targetRes" property="purviewOprList">
   <tr><td height="21" class="unnamed4"> </td><td   height="21" class="unnamed4"> </td>
   <td   height="21" class="redzi">
   <bean:write name="targetOpr"  property="cn"/></td>
   </tr>
   </logic:iterate>
  
   </logic:iterate>
  
   </logic:iterate>
   </table>
  
  结论
  
  多级迭代和单层差不多,唯一注意的就是 id <bean:write 中的 name 的对应,上级 logic id 与下级 logic name 对应,并且取出来的要是个 Collection,name id 不一定实际需要这个 bean ,都是虚拟的。

posted @ 2006-09-26 11:51 Bruce 阅读(892) | 评论 (0)编辑 收藏