??xml version="1.0" encoding="utf-8" standalone="yes"?>
1)UnabletoreadTLD"META-INF/c.tld"fromJAR
DeleteServlet.jarandjsp.jarfromWEB-INF/lib.
2)AntTips:
a)<classpath>
<pathelementpath="${classpath}"/>
<pathelementlocation="lib/helper.jar"/>
</classpath>
b)<classpath>
<
pathelementpath="${classpath}"/
>
方式
?/span>
Q引用特定的变量
<
filesetdir="lib"
>
方式
?/span>
Q指向特定的文g?/span>
<includename="**/*.jar"/>
</fileset>
<
pathelementlocation="classes"/
>
方式
?/span>
Q指向单个目?/span>
<
dirsetdir="${build.dir}"
>
方式
?/span>
Q指向特定目录集
<includename="apps/**/classes"/>
<excludename="apps/**/*Test*"/>
</dirset>
<
filelistrefid="third-party_jars"/
>
方式
?/span>
Q引用指定文件列?/span>
</classpath>
c) <copy todir="${web.inf.classes}">
<fileset dir="src/resources">
<include name="**/spring/*.xml" />
<include name="**/xfire/*.xml" />
</fileset>
<fileset dir="src/main">
<include name="**/*.xml" />
</fileset>
</copy>
3)Failed to setup clustering", what does it mean?
[JBossCacheService][main] jboss.cache:service=TomcatClusteringCache service to Tomcat clustering not found
[JBossCacheManager][main] JBossCacheService to Tomcat clustering not found
[TomcatDeployer][main] Failed to setup clustering, clustering disabled
There's two possibilities here:
1) Since 3.2.6, HTTP session replication is based on JBossCache, and more precisely the TomcatClusteringCache service.In 3.2.6, 3.2.7, 4.0.1 and 4.0.1SP1, the dependency on this service is missing in Tomcat's jboss-service.xml. To fix it, please edit /all/deploy/jbossweb-tomcat5x.sar/META-INF/jboss-service.xml and enable the <depends optional-attribute-name="CacheName?"> element, update the MBean ObjectName as well as the <depends> element itself.
The resulting code should look as follows:
<!--
Configuration for HTTP Session Clustering using JBossCache
-->
<depends>jboss.cache:service=TomcatClusteringCache</depends>
instead of
<!--
Configuration for HTTP Session Clustering using JBossCache
-->
<!--
<depends optional-attribute-name="CacheName">jboss.cache:service=TreeCache</depends>
-->
2) This error could also come up if you're trying to remove the clustering capabilities from the all configuration as explained in JBossASTuningSliming. Even though you might have modified jbossweb-tomcat5x.sar/META-INF/jboss-service.xml to remove the dependency on
jboss.cache:service=TomcatClusteringCache
, if the web application is deployed as
<distributable/>
, AS will try starting up
jboss.cache:service=TomcatClusteringCache
, for HTTP session replication. In this case, the ERROR message should not be considered as a failure because if it can't start it up, it'll log the ERROR but will continue working as normal.
4) 一ơ性导出所有oracle sequence
select 'create sequence ABEL.'|| SEQUENCE_NAME || ' minvalue '||MIN_VALUE||' maxvalue '||MAX_VALUE||' start with '||LAST_NUMBER||' increment by '||INCREMENT_BY||' cache '||CACHE_SIZE||' ;' from dba_sequences where SEQUENCE_OWNER = 'TEEMA'
5) Ora-01033: Oracle initialization or shutdown in process.
Cocoon 是一U?Java 服务器框Ӟ它允怋?XSLTQXML 样式表语a转换 (XML Stylesheet Language-Transformation)Q{换动态发?XML 内容。通过依靠 XML 描述内容以及使用 XSLT 内容{换成多种格式QCocoon 提供了用于构建内宏V逻辑和表C在很大E度上彼此分ȝ应用E序的^台?
Cocoon 使用道的概忉|描述内容发布到 Web 的过E。管道由一些输入数据以及随后对它进行的一些处理步骤构成。每个处理步骤接受前一步的输出作ؓ输入Q一直到辄道的末端q生最l输出。它包含各种各样的可重用lgQ这些组件可以配|成使用最低限度的 Java 开发生成复杂的行ؓ。例如,通过单独使用 XML ?XSLTQCocoon 可用于:
首先Q处?SPAN lang=EN-US> XML 文可分成几个离散的步骤。这些步骤的l合描述处理道。管道由输入、某些处理以及输出构成。Cocoon 2 使用 SAX 事g作ؓ每个处理步骤之间的连接?BR>W二Q可以用特D类型的lg来对道中的每个阶段建模。例如,用生成器生成输入Q用序列化器生成输出?BR>W三Q对用户h的响应包括确定ؓhQ与其输入一P服务的正管道,然后指示道执行其处理以生成l用L响应?
Cocoon 包含许多常规道lgQ可以用有用的方法将它们q接h。根据这些组件在道中扮演的角色Q可以将它们分组成几U完全不同的cd?o:p>
Cocoon 道通常臛_q成器和序列化器组成,但可能含有Q意数量的处理步骤。将数据作ؓ SAX 事g通过 Cocoon 道传递?
生成?/SPAN>负责d数据源(例如Q文ӞQ然后将该数据作Zpd SAX 事g传递到道。因此,最单的生成器是 SAX 解析器。通常QQ何可以被映像成一pd SAX 事g的数据源都可以成为生成器的基?
?Cocoon 中有许多可用的生成器。最有用的是Q?o:p>
阅读?/SPAN>?SPAN lang=EN-US> Cocoon 道模型中的特例Q因为它们不是理?XML 的组件。阅d只是讉K外部资源Q然后将它直接复制到响应。通常使用它们来提供静态文Ӟ例如Q图像或 CSS 样式表)。可以将阅读器视包含的管道;它们生成输入数据Q然后将数据序列化成响应?o:p>
转换?/SPAN>?SPAN lang=EN-US> Cocoon 道中的主要处理步骤。它们接?SAX 事g作ؓ输入Q执行一些有用的处理Q然后将l果作ؓ SAX 事g传入道。一U查看{换器的有用方法是作ؓ?SAX 事g通过它时修改 SAX 事g的lg。在q一点上Q它们类g SAX qo器?
使用最q泛的{换器?XSLT 转换器。它其输入传递到执行 XSLT 转换?XSLT 处理器中。然后将转换的结果作?SAX 事g反馈到管道?
操作是将附加动态行为插入管道的一U方法,q且通常为特D应用程序定制。但是,某些一般的操作?Cocoon 捆在一P例如Q执行数据库交互Q表单验证和发送邮件等。操作的成功完成q会影响是否执行后箋处理步骤?o:p>
序列化器?SPAN lang=EN-US> Cocoon 道中的端点。它们负责接收直接从生成器(在可能最短的道中)或者以前的处理步骤Q例如{换器Q生的 SAX 事g,然后它们解释成适合于响应的格式。特定格式取决于正在使用的确切序列化器?
最单的序列化器?XML 序列化器Q它只是?SAX 事g转换?XML 文。其它序列化器可以生?HTML、纯文本、PDF 文档甚至囑փ。所有这些序列化器都期望 SAX 事g符合一个特D的 XML 词汇表:
接受 XML 内容、对它进行处理,然后为其提供多种格式的能力是 Cocoon 框架的真正力量所在?
MҎ道可能涉及某些条g节。例如,切的处理步骤可能取决于h参数、用h览器{之cȝ因素?SPAN lang=EN-US>
匚w?/I>是两个条件组件中最单的部分Q等价于单的 if
语句。如果某个条件ؓ真,则对Ҏ道或者管道的一节进行求倹{?BR> W二U条件组件是选择?/I>Q它?if-then-else
语句cM。当几个选项之一可用时用选择器,它通常用于在管?I>?/I>创徏条g节,而匹配器则用于测试是否应该进入一个特D管道?BR> q些lg中的每一个都有几U实现。它们都遵@试h某些斚wQ例如,L名、用户代理、参数或 URLQ或用户会话的公共模式。可以用通配W或正则表达式来完成匚wQ而通常选择器枚举所有可能的倹{?BR style="mso-special-character: line-break">
Ҏ收请求和为响应提供服务的逻辑周期的描q可以归U_下:
Ҏ收请求和为响应提供服务的逻辑周期的描q可以归U_下:
q是 Cocoon 用来?XML 发布?Web 的基本请?响应周期。要理q一周期QCocoon 提供了一个称?sitemap ?XML 配置文g?o:p>
?SPAN lang=EN-US> Cocoon 部v?Tomcat 中很单,只需?cocoon.war
复制?$CATALINA_HOME/ webapps
目录中,然后重新启动 Tomcat?BR> 除了sitemapQCocoon 只有两个配置文g。可以在 $CATALINA_HOME/webapps/cocoon/WEB-INF
中找到它们:
log.xconfQ配|?Cocoon 日志记录。Cocoon ?Apache Log4J 用于内部日志记录Q请参阅参考资?/SPAN>Q。缺省情况下QCocoon 日志文件写?$CATALINA_HOME\webapps\cocoon\WEB-INF\logs
?SPAN lang=EN-US>
cocoon.xconfQ配|?Cocoon 高速缓存、数据源和许多其它高U选项?BR> Z开发目的,?cocoon.xconf
中进行一处更Ҏ很有帮助的。找C列项Q?BR><sitemap file="sitemap.xmap" reload-method="asynchron" check-reload="yes" logger="sitemap"/>
现在Q将 reload-method
属性的值更改ؓ synchron
。这改变?SPAN lang=EN-US> Cocoon 如何对网站地囄更改作出响应Q网站地图是配置 Cocoon 应用E序的中心位|。将行ؓ更改?synchon
意味着 Cocoon 在对Q何请求提供服务之前立即作用于更改。缺省异步行为意味着它将在后台读取更改,因此它们不会马上显C出来。在开发期_当立即结果是更可取的Q但是对于必ȝl尽可能快的为用h务的zd应用E序来说q不是最理想的时候,q可能o人沮丧?o:p>
|站地图是管?SPAN lang=EN-US> Cocoon |站的中心位|,它完成两个功能:
下面是一个带说明的比较完整的配置文gQ?/SPAN>
<?xml version="1.0" encoding="UTF-8"?>
<map:sitemap
xmlns:map="http://apache.org/cocoon/sitemap/1.0">
<map:components>
<map:generators default="file">
<map:generator name="file" src="org.apache.cocoon.generation.FileGenerator"/>
<map:generator name="csv" src="com.mycompany.CSVGenerator"/>
</map:generators>
<map:transformers default="xslt">
<map:transformer name="xslt" src="org.apache.cocoon.transformation.TraxTransformer"/>
<map:transform src="transforms/content2rss.xsl"/>
<map:transform src="transforms/content2svg.xsl"/>
<map:transform src="transforms/content2fo.xsl"/>
<!--Cocoon 支持从网站地图中传递参数。第一U方法是使用 map:parameter 元素来完成该d?/SPAN>
参数?/SPAN> name ?/SPAN> value 都被指定?/SPAN> map:parameter 元素的属性?/SPAN>
使用q一Ҏ固定的和动态的参数都传递到样式表中是有可能的?/SPAN>
W二个参数元素的值将由匹配模式中的第一个通配W设|?/SPAN>
只要样式表包?/SPAN> xsl:param 元素Q参数就能正地被传递到转换?/SPAN>-->
<map:transform src="transforms/content2html.xsl">
<map:parameter name="myFixedParam" value="fixed-value"/>
<map:parameter name="myDynamicParam" value="{1}"/>
</map:transform>
<!--另一U将参数传递到样式表的Ҏ允许传递所?/SPAN> URL h参数。例如,如果?/SPAN>
http://localhost:8080/content.html?param1=value1¶m2=value2 的请求导致触发这个管道,
则两个参敎ͼparam1 ?/SPAN> param2Q将被传递到样式表?/SPAN> -->
<map:transform src="transforms/content2html.xsl">
<map:parameter name="use-request-parameters" value="true"/>
</map:transform>
<!--
当请求中可能被传递的参数个数是可变时Q这一Ҏ很有用。但是,q是以牺牲一Ҏ能ZLQ因?/SPAN> Cocoon 对用这一Ҏ的{换的l果q行高速缓存的能力低于那些使用固定参数的{换。如果Q?/SPAN> URL 参数改变了,即不由样式表直接用,也不会用高速缓存的l果?/SPAN>-->
</map:transformers>
<map:readers default="resource">
<map:reader name="resource" src="org.apache.cocoon.reading.ResourceReader"/>
</map:readers>
<map:serializers default="html">
<map:serialize type="xml"/>
<map:serializer name="xml" mime-type="text/xml" src="org.apache.cocoon.serialization.XMLSerializer"/>
<map:serializer name="html" mime-type="text/html" src="org.apache.cocoon.serialization.HTMLSerializer"/>
<map:serializer name="svg2png" src="org.apache.cocoon.serialization.SVGSerializer" mime-type="image/png"/>
<map:serializer name="fo2pdf" src="org.apache.cocoon.serialization.FOPSerializer" mime-type="application/pdf"/>
</map:serializers>
<map:matchers default="wildcard">
<map:matcher name="wildcard" src="org.apache.cocoon.matching.WildcardURIMatcher"/>
</map:matchers>
</map:components>
<map:pipelines>
<map:pipeline>
<map:match pattern="index.html">
<map:read src="static/index.html" mime-type="text/html"/>
</map:match>
</map:pipeline>
<map:pipelines>
<map:pipeline>
<map:match pattern="*.css">
<map:read src="styles/{1}.css" mime-type="text/css"/>
</map:match>
<map:match pattern="**.html">
<map:read src="static/{1}.html" mime-type="text/html"/>
</map:match>
</map:pipeline>
<!--
单一星号与Q意数目的字符匚wQ除了正斜杠
双星号与包括正斜杠之外的L数目字符匚w
index.html 的匹配模式应该在 *.html 之前声明Q否则,它将永远不会被匹配?/SPAN>
-->
<!--
首先Q声明管道以及用来触发它的匹配模式:
-->
<map:pipe>
<map:match pattern="content/*.html">
<!--下一步,d一个生成器以从 content 目录中读?/SPAN> XML 文Q?/SPAN>-->
<map:generate src="content/{1}.xml"/>
<!--下一步,d一个{换器来通过使用特定样式表{?/SPAN> XML 文Q?/SPAN>-->
<map:transform src="transforms/content2html.xsl"/>
<!--最后,使用一个序列化器将转换l果变成q回l用L HTML 文Q?/SPAN>-->
<map:serialize type="html"/>
</map:match>
</map:pipe>
<!--
h URL http://localhost:8080/content/document.html 触发q一道q Cocoon 首先?/SPAN> document.xml q行解析Q然后在结果传回浏览器之前使用 $COCOON_HOME/transforms/content2html.xsl 来{换它?/SPAN>
-->
</map:sitemap>
Avalon原意?凯尔Ҏ传说中的西方乐土?据说亚瑟王及光下死后尸体被Ud该岛?BR>Avalon是五个子目的父目QFramework、Excalibur(亚瑟王的剑)、LogKit、Phoenix(长生鸟、凤?、和Cornerstone(墙角?。Avalon把重Ҏ在服务器端编E和让以服务器应用ؓ中心的项目的设计和维护变得更Ҏ。Avalon可被描述Z个包含了实现的框架?/P>
Framework
Avalon Framework是Avalon大伞下的所有其它项目的基础。它定义了接口、契U(contractsQ和Avalon的缺省实现。Framework大部分工作|于其中Q因此也是最为成熟的目?BR> 框架q个词在应用E序中的含义很广泛。重Ҏ在单一行业的框架被UCؓ垂直市场框架Q例如医药系l或通信pȝ。原因是同样的框架不能胜d它行业。具有很好通用性,可用于多个行业的框架被称为水q_场框架。Avalon是一个水q_场框架。您可以使用Avalon的Framework构徏垂直市场框架?BR> 用Avalon构徏的最有说服力的垂直市场框架的例子是Apache Cocoon出版框架。Apache CocoonW?版是使用Avalon的Framework、Excalibur和LogKit目构徏的。它利用了Framework中的接口和契U,让开发者能用更的旉理解Cocoon是如何工作的。它也有效地利用了Excalibur提供的数据源理和组件管理代码,q样它就不必重新发明轮子了。最后,它用了LogKit来处理出版框架中所有的日志问题?/P>
Excalibur
Avalon Excalibur是一l服务器端组Ӟ您可以在自己的项目中使用它们。它包括了池QpoolingQ的实现、数据库q接理和其它一些组件管理的实现?BR>
LogKit
Avalon LogKit是一个高速日志记录工具集QFramework、Excalibur、Cornerstone和Phoenix都用到它。它的模型与JDK 1.4 Logging package采用相同的原理,但与JDK 1.2+兼容?/P>
Phoenix
Avalon Phoenix是服务器核心Q它理服务QServiceQ实Cؓ服务器端lgQ称作BlockQ的发布和执行。主要采用了SOP思想[面向服务的编E(Service Oriented Programming QSOPQ的思想是把pȝ划分为由pȝ提供的一些服务]。Phoenix把每一U要提供的设施看作是一Ҏ务,q定接口和相关契约l成。服务的实现被称为Block。一个服务器E序是由多种服务l成的,认识q一点很重要?BR>
Cornerstone
Avalon Cornerstone是一lBlock或服务,q些Block可以布v在Phoenix环境中。这些Block包括了socket理和Block之间的Q务调度?BR>
Scratchpad
Scratchpadq不是一个真正的正式目Q而是那些q没准备好放入Excalibur中的lg的一个时区域。这些组件品质差别较大,它们的API也不保证会不变,直到它们被提升到Excalibur目为止?BR>
java代码: |
package com.xindeco.business ; import java.io.*; import java.sql.*; import java.util.*; import javax.sql.*; import java.lang.IllegalAccessException; import java.lang.reflect.InvocationTargetException; import org.apache.commons.beanutils.BeanUtils; public class DAO { protected DataSource ds; /** * 说明:取得当前查询的总记录数 */ public int getRows () { return this.count; } public void rsHandler (ResultSet rs, int offset, int limit) { try { count = 0; rs.absolute ( -1) ; count = rs.getRow () ; if (offset <= 0) { rs.beforeFirst () ; } else { rs.absolute (offset) ; } } catch (Exception e) { e.printStackTrace () ; } } public DAO(DataSource ds) { this.ds = ds; } public void setDataSource(DataSource ds) { this.ds = ds; } protected void close(ResultSet rs) { if (rs != null) { try { rs.close(); } catch (SQLException e) { } rs = null; } } protected void close(PreparedStatement pstmt) { if (pstmt != null) { try { pstmt.close(); } catch (SQLException e) { } pstmt = null; } } protected void close(Connection conn) { if (conn != null) { try { conn.close(); } catch (SQLException e) { e.printStackTrace(); } conn = null; } } protected void rollback(Connection conn) { if (conn != null) { try { conn.rollback(); } catch (SQLException e) { e.printStackTrace(); } conn = null; } } } |
java代码: |
package com.xindeco.business; import java.io.*; import java.sql.*; import java.util.*; import javax.sql.*; import com.xindeco.common.dbconn.DbConn; public class CertificateDAO extends DAO { public NationDAO(DataSource ds) { super(ds); } public List findCertificateList(int offset,int limit) throws SQLException { int countRows = 0 ; ArrayList list = null ; Connection conn = null; PreparedStatement pstmt = null; ResultSet rs = null; try { conn = ds.getConnection(); String sql = "SELECT certificateID, certificateCode,certificateName,photoURL," + "description,graduateID FROM TCertificate " ; pstmt = conn.prepareStatement(sql); rs = pstmt.executeQuery(); /*Ҏ标进行处理,rsHandler Ҏ在父cDAO?/ this.rsHandler(rs,offset,limit); if (rs != null && rs.next ()) { list = new ArrayList () ; do { countRows++ ; list.add (rs2VO (rs)) ; } while ( (countRows++ < limit) && rs.next ()) ; } close(rs); close(pstmt); } catch (SQLException e) { close(rs); close(pstmt); rollback(conn); e.printStackTrace(); } finally { close(conn); } return list ; } private CertificateVO rs2VO (ResultSet rs) { try { CertificateVO certificateVO = new CertificateVO () ; certificateVO.setCertificateID (rs.getInt ("certificateID")) ; certificateVO.setCertificateCode (rs.getString ("certificateCode")) ; certificateVO.setCertificateName (rs.getString ("certificateName")) ; certificateVO.setPhotoURL (rs.getString ("photoURL")) ; certificateVO.setDescription (rs.getString ("description")) ; certificateVO.setGraduateID (rs.getInt ("graduateID")) ; return certificateVO ; } catch (Exception ex) { ex.printStackTrace () ; return null ; } } } |
java代码: |
package com.xindeco.presentation; import javax.sql.* ; import java.util.* ; import javax.servlet.http.* ; import javax.servlet.* ; import org.apache.struts.action.* ; import org.apache.struts.util.* ; import com.xindeco.common.Pager; import com.xindeco.business.graduatedata.CertificateDAO ; public class CertificateAction extends Action { private static final int PAGE_LENGTH = 5 ; //每页昄5条记? public ActionForward execute (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { ActionForward myforward = null ; String myaction = mapping.getParameter () ; if (isCancelled (request)) { return mapping.findForward ("failure") ; } if ("".equalsIgnoreCase (myaction)) { myforward = mapping.findForward ("failure") ; } else if ("LIST".equalsIgnoreCase (myaction)) { myforward = performList (mapping, form, request, response) ; } else { myforward = mapping.findForward ("failure") ; } return myforward ; } private ActionForward performList (ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) { try { DataSource ds = (DataSource) servlet.getServletContext().getAttribute(Action.DATA_SOURCE_KEY); CertificateDAO certificateDAO = new CertificateDAO (ds) ; int offset = 0; //页时的起始记录所在游? int length = PAGE_LENGTH; String pageOffset = request.getParameter("pager.offset"); if (pageOffset == null || pageOffset.equals("")) { offset = 0; } else { offset = Integer.parseInt(pageOffset); } List certificateList = certificateDAO .findCertificateList (offset,length) ; int size = certificateDAO.getRows(); // 取得总记录数 String url = request.getContextPath()+"/"+mapping.getPath()+".do"; String pagerHeader = Pager.generate(offset, size, length, url); //分页处理 request.setAttribute ("pager", pagerHeader) ; request.setAttribute ("list", certificateList) ; } catch (Exception e) { e.printStackTrace(); return mapping.findForward ("error") ; } return mapping.findForward ("success") ; } } |
java代码: |
<%@ page contentType="text/html; charset=GBK" %> <%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %> <table bgcolor="#666666" cellpadding="1" cellspacing="0" border="0" width="500"> <tr> <td> <table cellpadding="0" cellspacing="0" border="0" width="500"> <tr> <td bgcolor="#fecc51">&</td> </tr> </table> </td> </tr> <tr> <td> <table cellpadding="0" cellspacing="0" border="0" width="500"> <tr> <td bgcolor="#d6e0ed"> &&<bean:message key="label.list4certificate"/> </td> </tr> <tr bgcolor="#FFFFFF"> <td width="5%"></td><td width="19%"></td><td width="76%"></td> </tr> <tr> <td> <table bgcolor="#f2f2f2" width="500" cellspacing="0" border="0"> <tr bgcolor="#bacce1"> <td><b><bean:message key="Certificate.select"/> </b></td> <td><b><bean:message key="Certificate.certificateID"/> </b></td> <td><b><bean:message key="Certificate.certificateCode"/></b></td> <td><b><bean:message key="Certificate.certificateName"/></b></td> <td><b><bean:message key="Certificate.view"/></b></td> ?/tr> <bean:write name="pager" property="description"/> <logic:equal name="pager" property="hasPrevious" value="true"> <a href="/graduatedata/list.do?viewPage=<bean:write name="pager" property="previousPage"/>" class="a02"> Previous </a> </logic:equal> <logic:equal name="pager" property="hasNext" value="true"> ?a href="/graduatedata/list.do?viewPage=<bean:write name="pager" property="nextPage"/>" class="a02"> Next ?/a> </logic:equal> <logic:notEmpty name="list" scope="request"> <logic:iterate id="certificate" name="list" type="com.xindeco.business.graduatedata.CertificateVO"scope="request"> <tr bgcolor="#FFFFFF"> ?td><html:text property="name" value="<bean:write name="certificate" property="certificateID" scope="page"/>"/> </td> ?td> <bean:write name="certificate" property="certificateID" scope="page"/></td> ?td> <bean:write name="certificate" property="certificateCode" scope="page"/></td> ?td> <bean:write name="certificate" property="certificateName" scope="page"/></td> ?td> <bean:write name="certificate" property="photoURL" scope="page"/></td> </tr> </logic:iterate> </logic:notEmpty> </table> </td> </tr> </table> </td> </tr> </table> |
java代码: |
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"> <struts-config> <form-beans> <form-bean name="certificateForm" type="com.xindeco.presentation.graduatedata.CertificateForm" /> </form-beans> <global-forwards> <forward name="error" path="/error/error.jsp" /> </global-forwards> <action-mappings> <action name="certificateForm" parameter="LIST" path="/graduatedata/list" scope="request" type="com.xindeco.presentation.graduatedata.CertificateAction" validate="true"> <forward name="success" path="/graduatedata/listcertificate.jsp" /> </action> </action-mappings> …? </struts-config> |
java代码: |
package com.xindeco.common; import java.util.* ; public class Pager { private static int MAX_PAGE_INDEX = 10; //脚昄多少? private static String HEADER = "Result page"; public static String generate(int offset, int length, int size, String url) { if (length > size) { String pref; if (url.indexOf("?") > -1) { pref = "&"; } else { pref = "?"; } String header = "<font face='Helvetica' size='-1'>"+HEADER+": "; if (offset > 0) { header += "&<a href=\""+url+pref+"pager.offset="+(offset-size)+"\">[<< Prev]</a>\n"; } int start; int radius = MAX_PAGE_INDEX/2*size; if (offset < radius) { start = 0; } else if(offset < length-radius) { start = offset - radius; } else { start = (length/size-MAX_PAGE_INDEX)*size; } for(int i=start;i<length && i < start + MAX_PAGE_INDEX*size;i+=size) { if (i == offset) { header += "<b>"+(i/size+1)+"</b>\n"; } else { header += "&<a href=\""+url+pref+"pager.offset="+i+"\">"+(i/size+1)+"</a>\n"; } } if(offset < length - size) { header += "&<a href=\""+url+pref+"pager.offset="+((int)offset+(int)size)+"\">[Next >>]</a>\n"; } header += "</font>"; return header; } else { return ""; } } } |