??xml version="1.0" encoding="utf-8" standalone="yes"?>欧美国产综合视频,首页国产精品,日韩专区中文字幕一区二区http://www.aygfsteel.com/keweibo/category/25865.htmlAs long as you are there to lead me ,I won't lose my way zh-cnTue, 20 Apr 2010 23:41:44 GMTTue, 20 Apr 2010 23:41:44 GMT60FreemarkerServlet in web.xmlhttp://www.aygfsteel.com/keweibo/articles/318771.htmlKEKEMon, 19 Apr 2010 13:16:00 GMThttp://www.aygfsteel.com/keweibo/articles/318771.htmlhttp://www.aygfsteel.com/keweibo/comments/318771.htmlhttp://www.aygfsteel.com/keweibo/articles/318771.html#Feedback0http://www.aygfsteel.com/keweibo/comments/commentRss/318771.htmlhttp://www.aygfsteel.com/keweibo/services/trackbacks/318771.html     <servlet-name>freemarker</servlet-name>
    <servlet-class>freemarker.ext.servlet.FreemarkerServlet</servlet-class>
    <init-param>
        <param-name>TemplatePath</param-name>
        <param-value>/</param-value>
    </init-param>
    <init-param>
        <param-name>NoCache</param-name>
        <param-value>true</param-value>
    </init-param>
    <init-param>
        <param-name>ContentType</param-name>
        <param-value>text/html</param-value>
    </init-param>
    <!-- FreeMarker settings: -->
    <init-param>
        <param-name>template_update_delay</param-name>
        <param-value>0</param-value> <!-- 0 is for development only! Use higher value otherwise. -->
    </init-param>
    <init-param>
        <param-name>default_encoding</param-name>
        <param-value>UTF-8</param-value>
    </init-param>
    <init-param>
        <param-name>locale</param-name>
        <param-value>zh_CN</param-value>
    </init-param>
    <init-param>
        <param-name>number_format</param-name>
        <param-value>0.##########</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>freemarker</servlet-name>
    <url-pattern>*.ftl</url-pattern>
</servlet-mapping>



KE 2010-04-19 21:16 发表评论
]]>
DisplayTag应用指南http://www.aygfsteel.com/keweibo/articles/160617.htmlKEKEWed, 14 Nov 2007 12:08:00 GMThttp://www.aygfsteel.com/keweibo/articles/160617.htmlhttp://www.aygfsteel.com/keweibo/comments/160617.htmlhttp://www.aygfsteel.com/keweibo/articles/160617.html#Feedback0http://www.aygfsteel.com/keweibo/comments/commentRss/160617.htmlhttp://www.aygfsteel.com/keweibo/services/trackbacks/160617.html文章出处:http://www.javaresearch.org/article/42943.htm
  DisplayTag是一个非常好用的表格昄标签Q适合MVC模式Q其主页?a >http://displaytag.sourceforge.net  
一、最单的情况Q未使用<display:column/>标签
  <%request.setAttribute( "test", new ReportList(6) );%>
  <display:table name="test" />
  标签遍历List里的每一个对象,q将对象里的所有属性显C出来。一般用于开发的时候检查对象数据的完整性?br />   
二、?lt;display:column/>标签的情?br /> <display:table name="test">
  <display:column property="id" title="ID" />
  <display:column property="name" />
  <display:column property="email" />
  <display:column property="status" />
  <display:column property="description" title="Comments"/>
</display:table>
   property对应List里对象的属性(用getXXX()Ҏ取得Q,title则对应表D头里的列名。定义列有两U方式:
   A?lt;display:column property="email" /> 
      使用<display:column/>标签里的property属性来定义
   B?lt;display:column title="email">email@it.com</display:column> 
      ?lt;display:column/>标签体里增加内容Q可以是帔RQ也可以用其他标{{?br />    两种方式比较Q用property属性来定义更加快速和利于排序?br />    
三、表格显C样式的定义
  A、在<display:table/>?lt;display:column/>标签里指定标准的html属性,烦琐
  B、修Ҏ式表
<display:table name="test" class="mars">
  <display:column property="id" title="ID" class="idcol"/>
  <display:column property="name" />
  <display:column property="email" />
  <display:column property="status" class="tableCellError" />
  <display:column property="description" title="Comments"/>
</display:table>
   通过class属性来指定所要应用的样式。可以在光认样式表里(./css/screen.cssQ直接修?br />    
四、标{֏得数据的数据?br />   有四U范?br />    pageScope 
   requestScope (默认)  <display:table name="test2" >
   sessionScope  <display:table name="sessionScope.holder.list" > 注意Q这里要指定范围Q非默认
   applicationScope 
   
五、通过增加id属性创建隐含的对象
<display:table name="test" id="testit">
    <display:column property="id" title="ID" />
    <display:column property="name" />
    <display:column title="static value">static</display:column>
    <display:column title="row number (testit_rowNum)"><%=pageContext.getAttribute("testit_rowNum")%></display:column>
    <display:column title="((ListObject)testit).getMoney()"><%=((ListObject)pageContext.getAttribute("testit")).getMoney()%></display:column>
</display:table>
   注意到在<display:table/>里增加了id属性,q时在page context里创Z一个隐含对象,指向List里的当前对象Q?br />    可以通过(ListObject)pageContext.getAttribute("id")来捕莯个对象。同时还创徏了一个id_rowNum对象Q同P?br />    通过pageContext.getAttribute("testit_rowNum")来捕P它仅仅代表当前行的行数?br />    有了q两个隐含对象,可以通过其他标签来访问,例如Jstl:
  <display:table id="row" name="mylist">
    <display:column title="row number" >
      <c:out value="${row_rowNum}"/>
    </display:column>
    <display:column title="name" >
      <c:out value="${row.first_name}"/>
      <c:out value="${row.last_name}"/>
    </display:column>
  </display:table>
  
六、显C部分数?br />    昄开始五条数据:通过讑֮length属?br /> <display:table name="test" length="5">
  <display:column property="id" title="ID" />
  <display:column property="email" />
  <display:column property="status" />
</display:table>
   昄W三到第八条数据Q通过讑֮offset和length属?br /> <display:table name="test" offset="3" length="5">
  <display:column property="id" title="ID" />
  <display:column property="email" />
  <display:column property="status" />
</display:table>  

七、对email和url地址的直接连?br />  <display:table name="test" >
  <display:column property="id" title="ID" />
  <display:column property="email" autolink="true" />
  <display:column property="url" autolink="true" />
 </display:table>
 如果要显C的对象里包含email和url地址Q则可以在display:column里直接设定autolink="true"来直接连?br />  
八、用装饰模式{换数据显C(写自q decorator Q?br />   A、对整个表格应用decorator
  <display:table name="test" decorator="org.displaytag.sample.Wrapper" >
      <display:column property="id" title="ID" />
      <display:column property="email" />
      <display:column property="status" />
      <display:column property="date" />
      <display:column property="money" />
  </display:table>
    org.displaytag.sample.Wrapper卌己写的decoratorQ它要承TableDecoratorc,看看它的一个方法:
        public String getMoney()
    {
        return this.moneyFormat.format(((ListObject) this.getCurrentRowObject()).getMoney());
    }
    很明显,它通过父类的getCurrentRowObject()Ҏ获得当前对象Q然后对其getMoney()Ҏq行‘Ҏ’
  B、对单独的column应用decorator
  <display:table name="test">
     <display:column property="id" title="ID" />
     <display:column property="email" />
     <display:column property="status" />
     <display:column property="date" decorator="org.displaytag.sample.LongDateWrapper" />
  </display:table>
    org.displaytag.sample.LongDateWrapper要实现ColumnDecorator接口Q它的方法:
        public final String decorate(Object columnValue)
    {
        Date date = (Date) columnValue;
        return this.dateFormat.format(date);
    }
    昄Q它获得不了当前对象Q因为它实现的是接口Q,仅仅是获得该对象的columnValueQ然?#8216;Ҏ’
    
九、创建动态连?br />    有两U方法创建动态连接:
   A、在<display:column/>里通过增加href、paramId、paramName、paramScope、paramProperty属?br />       href             基本的URL 地址
      paramId          加在URL 地址后的参数名称
      paramName        数据bean的名Uͼ一般ؓnullQ即使用当前List里的对象Q?br />       paramScope       数据bean的范_一般ؓnull
      paramProperty    数据bean的属性名Uͼ用来填充URL 地址后的参数?br /> <display:table name="sessionScope.details">
  <display:column property="id" title="ID" href="details.jsp" paramId="id" />
  <display:column property="email" href="details.jsp" paramId="action" paramName="testparam" paramScope="request" />
  <display:column property="status" href="details.jsp" paramId="id" paramProperty="id" />
</display:table>  
    q种Ҏ便直接,但缺Ҏ无法产生cMdetails.jsp?id=xx&action=xx的复合URL
   B、应用decorator 创徏动态连接:
<display:table name="sessionScope.details" decorator="org.displaytag.sample.Wrapper" >
  <display:column property="link1" title="ID" />
  <display:column property="email" />
  <display:column property="link2" title="Actions" />
</display:table>
   org.displaytag.sample.Wrapper里的ҎQ?br />     public String getLink1()
    {
        ListObject lObject= (ListObject)getCurrentRowObject();
        int lIndex= getListIndex();
        return "<a href=\"details.jsp?index=" + lIndex + "\">" + lObject.getId() + "</a>";
    }


    public String getLink2()
    {
        ListObject lObject= (ListObject)getCurrentRowObject();
        int lId= lObject.getId();

        return "<a href=\"details.jsp?id=" + lId
            + "&action=view\">View</a> | "
            + "<a href=\"details.jsp?id=" + lId
            + "&action=edit\">Edit</a> | "
            + "<a href=\"details.jsp?id=" + lId
            + "&action=delete\">Delete</a>";
    }

十、分?br />    实现分页非常的简单,增加一个pagesize属性指定一ơ想昄的行数即?br /> <display:table name="sessionScope.test" pagesize="10">
    <display:column property="id" title="ID" />
    <display:column property="name" />
    <display:column property="email" />
    <display:column property="status" />
</display:table>

十一、排?br />    排序实现也是很简单,在需要排序的column里增加sortable="true"属性,headerClass="sortable"仅仅?br />    指定昄的样式。column里的属性对象要实现Comparable接口Q如果没有的话可以应用decorator
   defaultsort="1"              默认W一个column排序
   defaultorder="descending"    默认递减排序
<display:table name="sessionScope.stest" defaultsort="1" defaultorder="descending">
  <display:column property="id" title="ID" sortable="true" headerClass="sortable" />
  <display:column property="name" sortable="true" headerClass="sortable"/>
  <display:column property="email" />
  <display:column property="status" sortable="true" headerClass="sortable"/>
</display:table>
  注意的是Q当同时存在分页时如果不指定sort=list,则排序仅仅针对的是当前页面,而不是整个List都进行排?br />   
十二、column 分组
   分组只是需要在column里增加group属?br /> <display:table name="test" class="simple">
  <display:column property="city" title="CITY" group="1"/>
  <display:column property="project" title="PROJECT" group="2"/>
  <display:column property="amount" title="HOURS"/>
  <display:column property="task" title="TASK"/>
</display:table>

十三、导出数据到其他格式Q页面溢出filter??Q?br />    ?lt;display:table/>里设定export="true"
   ?lt;display:column/>里设定media="csv excel xml pdf" 军_该字D在导出到其他格式时被包不包含,不设定则都包?br />    <display:setProperty name="export.csv" value="false" />
   军_该种格式能不能在面中导?br /> <display:table name="test" export="true" id="currentRowObject">
  <display:column property="id" title="ID"/>
  <display:column property="email" />
  <display:column property="status" />
  <display:column property="longDescription" media="csv excel xml pdf" title="Not On HTML"/>
  <display:column media="csv excel" title="URL" property="url"/>
  <display:setProperty name="export.pdf" value="true" />
  <display:setProperty name="export.csv" value="false" />
</display:table>

十四、配|属性,覆盖默认
  两种ҎQ?br />   A、在E序classpath下新建displaytag.properties文g
  B、对于单个表|应用<display:setProperty>标签
  具体可配|的属性:http://displaytag.sourceforge.net/configuration.html
  
十五、一个完整的例子
<display:table name="test" export="true" sort="list" pagesize="8">
  <display:column property="city" title="CITY" group="1" sortable="true" headerClass="sortable"/>
  <display:column property="project" title="PROJECT" group="2" sortable="true" headerClass="sortable"/>
  <display:column property="amount" title="HOURS"/>
  <display:column property="task" title="TASK"/>
</display:table> 
   sort="list" Ҏ个listq行排序
   导出数据到其他格式时Qgroup无效



KE 2007-11-14 20:08 发表评论
]]>
关于displaytag1.1的两U分?/title><link>http://www.aygfsteel.com/keweibo/articles/160614.html</link><dc:creator>KE</dc:creator><author>KE</author><pubDate>Wed, 14 Nov 2007 11:55:00 GMT</pubDate><guid>http://www.aygfsteel.com/keweibo/articles/160614.html</guid><wfw:comment>http://www.aygfsteel.com/keweibo/comments/160614.html</wfw:comment><comments>http://www.aygfsteel.com/keweibo/articles/160614.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/keweibo/comments/commentRss/160614.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/keweibo/services/trackbacks/160614.html</trackback:ping><description><![CDATA[<p><span style="color: red">文章出处:http://blog.csdn.net/shrek_xu/archive/2006/06/01/767885.aspx<br /> </span><br /> 最q因为项目需?所以想把原来用的displaytag1.0升为displaytag1.1,其实升的原因很?1.0实在是太M,每次分页q需要将所有数据一ơ蝲?效率低到无法忍受:)</p> <p>1.1版最大的改进可以说是l于支持了大家期待以久的分次加蝲功能?xC多数据就载入多少数据.1.1版本支持两种方式的分?W一U是实现?font face="Courier New">org.displaytag.pagination.PaginatedList</font> 接口,W二U是在页面和后台同时做修Ҏ实现分页功能.在网上关于第二种分页的用方法介l的非常?而且官方文档上面写的也比较详l?所以在q里我主要介l自己是如何使用W一U方式进行分늚,且这U方式也是官Ҏ荐分|?自己摸烦?呵呵,不好不要见?</p> <p>首先写一个此接口的实现类</p> <p>/**<br />  * PaginatedListImpl<br />  * User: shrek_xu<br />  * Date: 2006-5-30<br />  * Time: 20:35:18<br />  * <br />  * totalNum 所有条目数?br />  * currentPage 当前所在页?br />  * objectsPerPage 每页昄条数<br />  * list 此页所需要显C的数据<br />  */<br /> public class PaginatedListHelper implements PaginatedList{<br />     private List list;<br />     private int pageNumber = 1;<br />     private int objectsPerPage = 20;<br />     private int fullListSize = 0;<br />     private String sortCriterion;<br />     private SortOrderEnum sortDirection;<br />     private String searchId;</p> <p>    public List getList() {<br />         return list;<br />     }</p> <p>    public void setList(List list) {<br />         this.list = list;<br />     }</p> <p>    public int getPageNumber() {<br />         return pageNumber;<br />     }</p> <p>    public void setPageNumber(int pageNumber) {<br />         this.pageNumber = pageNumber;<br />     }</p> <p>    public int getObjectsPerPage() {<br />         return objectsPerPage;<br />     }</p> <p>    public void setObjectsPerPage(int objectsPerPage) {<br />         this.objectsPerPage = objectsPerPage;<br />     }</p> <p>    public int getFullListSize() {<br />         return fullListSize;<br />     }</p> <p>    public void setFullListSize(int fullListSize) {<br />         this.fullListSize = fullListSize;<br />     }</p> <p>    public String getSortCriterion() {<br />         return sortCriterion;<br />     }</p> <p>    public void setSortCriterion(String sortCriterion) {<br />         this.sortCriterion = sortCriterion;<br />     }</p> <p>    public SortOrderEnum getSortDirection() {<br />         return sortDirection;<br />     }</p> <p>    public void setSortDirection(SortOrderEnum sortDirection) {<br />         this.sortDirection = sortDirection;<br />     }</p> <p>    public String getSearchId() {<br />         return searchId;<br />     }</p> <p>    public void setSearchId(String searchId) {<br />         this.searchId = searchId;<br />     }</p> <p>}</p> <p>然后在用的时候只需要创建此cȝ一个实?且将所需要的参数通过setҎ赋Dd可以?/p> <p> int page;</p> <p>/*<br />  *其中request中的page参数为displaytag中的默认当前|,当然也可以?TableTagParameters.SORT_AMOUNT_PAGE来表C当前页?br />  */<br />  if(request.getParameter("page")!=null && !"".equals(request.getParameter("page"))){<br />          page=Integer.parseInt(request.getParameter("page"));<br />   }else{<br />          page=1;<br />   }<br /> PaginatedList paginaredList=new PaginatedListHelper();</p> <p> paginaredList.setPageNumber(page);</p> <p>// 此页要显C的list数据</p> <p>List list=.......;</p> <p>paginaredList.setList(list);</p> <p>// d有多数?他会Ҏ所有数目和每页数目自动l计|</p> <p>paginaredList.setFullListSize(...);</p> <p>// 如果你只讑֮q几个参?那么其余的参数将会默认ؓ你实现类中所赋的初?/p> <p>最?你还需要将q个实例攑օ到request或session中去,好让displaytag知道q个是外部分?/p> <p>request.setAttribute("pageList",paginaredList);</p> <p>在前台只需象下面这样写可以了</p> <p><display:table name="${pageList}" id="list" requestURI=""></p> <p>     <display:column property="id"/></p> <p></display:table></p> <p>最开始我Ҏơ都要传入d有多条数据表示疑问,认ؓq个没有必要,只需要第一ơ传入就可以?但是后来仔细x,因ؓ整个分页q程是动态的,所?很有可能在你页的同?原来的数据已l发生了变化,所以每ơ传入L目是很有必要?/p> <p>如果大家需要{?请你也附上此文连?/p> <img src ="http://www.aygfsteel.com/keweibo/aggbug/160614.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/keweibo/" target="_blank">KE</a> 2007-11-14 19:55 <a href="http://www.aygfsteel.com/keweibo/articles/160614.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>toGBK(使用EL函数)http://www.aygfsteel.com/keweibo/articles/146939.htmlKEKEThu, 20 Sep 2007 14:40:00 GMThttp://www.aygfsteel.com/keweibo/articles/146939.htmlhttp://www.aygfsteel.com/keweibo/comments/146939.htmlhttp://www.aygfsteel.com/keweibo/articles/146939.html#Feedback0http://www.aygfsteel.com/keweibo/comments/commentRss/146939.htmlhttp://www.aygfsteel.com/keweibo/services/trackbacks/146939.htmlToGBKFuncs.java
package dgut.ke.el;

public class ToGBKFuncs {

 public static String toGBK(String str ,String charset)
   throws java.io.UnsupportedEncodingException
 {
      return new String(str.getBytes(charset),"GBK");
 }
}
WEB-INF\tlds\myfuncs.tld
<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-jsptagliblibrary_2_0.xsd"
  version="2.0">
  
  <tlib-version>1.0</tlib-version>
  
  <uri>/myfuncs</uri>
  
  <function>
   <name>toGBK</name>
   <function-class>dgut.ke.el.ToGBKFuncs</function-class>
   <function-signature>
    java.lang.String toGBK(java.lang.String,java.lang.String)
   </function-signature>
  </function>
</taglib>
 test.jsp

<%@ page language="java" pageEncoding="GBK"%>
<%@ taglib prefix="myfn" uri="/myfuncs" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>Tag</title>
  </head>
  <body>
     Ƣ迎你的到来 ${myfn:toGBK(param.username,"ISO8859-1")} !
  </body>
</html>


 



KE 2007-09-20 22:40 发表评论
]]>
解决DisplayTag有中文条件时的分问?/title><link>http://www.aygfsteel.com/keweibo/articles/145314.html</link><dc:creator>KE</dc:creator><author>KE</author><pubDate>Sat, 15 Sep 2007 02:34:00 GMT</pubDate><guid>http://www.aygfsteel.com/keweibo/articles/145314.html</guid><wfw:comment>http://www.aygfsteel.com/keweibo/comments/145314.html</wfw:comment><comments>http://www.aygfsteel.com/keweibo/articles/145314.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.aygfsteel.com/keweibo/comments/commentRss/145314.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/keweibo/services/trackbacks/145314.html</trackback:ping><description><![CDATA[<p>很早开始用DisplayTag了,真得很方便,不用考虑分页Q表格等问题?/p> <p>但是有一个问题一直困扰我Q就是有中文作ؓ表单提交内容的时候,页׃能用了,中文变成了ؕ码?/p> <p>表单传送时Q?!--startfragment --> form的提交采用的是PostҎQ这没错Q但链接采用的是GetҎQ问题就出在q里Q因为和Tomcat4相比QTomcat5的post和get采用的方式不再相同了Q汉字编码的实现方式也不同了?/p> <p>Post是将地址传送一ơ,form的数据单独提交,而Get则是地址和参C起传送,传送的不止是form的数据?br /> <br /> <!--startfragment --> <a>默认情况下,Tomcat对请求采用的默认~码是ISO-8859-1Q?/a><a>q样我们提交的汉字被认ؓ是ISO-8859-1的编码,所以在E序中接收时昄q</a>?nbsp;<!--startfragment --> 在过滤器中调用request.setCharacterEncoding("GBK")Q那么Post上来的汉字将被认为是GBK~码Q而Tomcat5对于Geth上来的编码ƈ不根据过滤器的设定L认编码方式,默认的依然是ISO-8859-1Q?a>所以,即你的面使用默认的编码方式进行编码,然后使用ISO-8859-1q行解码Q得到的l果也不?/a>?</p> <p>解决ҎQ?br /> <a>在Server.xml的connector部分讑֮URIEncoding的|Ҏ~码方式指定自己的?/a>可以了<br /> 例如QURIEncoding="GB2312"</p> <p> </p> <br /> <div align="center"><script type="text/javascript"><!--google_ad_client = "pub-9648238652058580"; google_ad_width="468;google_ad_height" = 60; google_ad_format="468x60_as" ; google_ad_type="text" ; google_ad_channel="" ; google_color_border="336699" ; google_color_bg="FFFFFF" ; google_color_link="0000FF" ; google_color_url="008000" ; google_color_text="000000" ;//--></script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script></div> <br /> <br /> <p id="TBPingURL">Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=679832</p> <img src ="http://www.aygfsteel.com/keweibo/aggbug/145314.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/keweibo/" target="_blank">KE</a> 2007-09-15 10:34 <a href="http://www.aygfsteel.com/keweibo/articles/145314.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>应用displaytag在struts中完成大数据量分?/title><link>http://www.aygfsteel.com/keweibo/articles/145313.html</link><dc:creator>KE</dc:creator><author>KE</author><pubDate>Sat, 15 Sep 2007 02:32:00 GMT</pubDate><guid>http://www.aygfsteel.com/keweibo/articles/145313.html</guid><wfw:comment>http://www.aygfsteel.com/keweibo/comments/145313.html</wfw:comment><comments>http://www.aygfsteel.com/keweibo/articles/145313.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/keweibo/comments/commentRss/145313.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/keweibo/services/trackbacks/145313.html</trackback:ping><description><![CDATA[<p>应用displaytag在struts中完成大数据量分|C,Oracle数据?/p> <p> </p> <p>JSP文gQ?/p> <p> </p> <div style="border-right: windowtext 0.5pt solid; padding-right: 5.4pt; border-top: windowtext 0.5pt solid; padding-left: 5.4pt; background: #e6e6e6; padding-bottom: 4px; border-left: windowtext 0.5pt solid; width: 95%; word-break: break-all; padding-top: 4px; border-bottom: windowtext 0.5pt solid"> <div><img id="_2_54_Open_Image" onclick="this.style.display='none'; document.getElementById('_2_54_Open_Text').style.display='none'; document.getElementById('_2_54_Closed_Image').style.display='inline'; document.getElementById('_2_54_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="_2_54_Closed_Image" style="display: none" onclick="this.style.display='none'; document.getElementById('_2_54_Closed_Text').style.display='none'; document.getElementById('_2_54_Open_Image').style.display='inline'; document.getElementById('_2_54_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif" align="top" /><span style="color: #000000; background-color: #ffff00"><%</span><span id="_2_54_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff">...</span><span id="_2_54_Open_Text"><span style="color: #000000; background-color: #f5f5f5">@ taglib uri</span><span style="color: #000000; background-color: #f5f5f5">=</span><span style="color: #000000; background-color: #f5f5f5">"</span><span style="color: #000000; background-color: #f5f5f5">/WEB-INF/displaytag.tld</span><span style="color: #000000; background-color: #f5f5f5">"</span><span style="color: #000000; background-color: #f5f5f5"> prefix</span><span style="color: #000000; background-color: #f5f5f5">=</span><span style="color: #000000; background-color: #f5f5f5">"</span><span style="color: #000000; background-color: #f5f5f5">disp</span><span style="color: #000000; background-color: #f5f5f5">"</span><span style="color: #000000; background-color: #f5f5f5"> </span></span><span style="color: #000000; background-color: #ffff00">%></span><span style="color: #000000"><br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" /><br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff"><</span><span style="color: #800000">disp:table </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="resultList"</span><span style="color: #ff0000"> export</span><span style="color: #0000ff">="true"</span><span style="color: #ff0000"> pagesize</span><span style="color: #0000ff">="100"</span><span style="color: #ff0000"> requestURI</span><span style="color: #0000ff">="logQueryAction.do"</span><span style="color: #ff0000"> sort</span><span style="color: #0000ff">="external"</span><span style="color: #ff0000"> id</span><span style="color: #0000ff">="element"</span><span style="color: #ff0000"> partialList</span><span style="color: #0000ff">="true"</span><span style="color: #ff0000"> size</span><span style="color: #0000ff">="resultSize"</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />          </span><span style="color: #0000ff"><</span><span style="color: #800000">disp:column </span><span style="color: #ff0000">property</span><span style="color: #0000ff">="operdate"</span><span style="color: #ff0000"> title</span><span style="color: #0000ff">="操作旉"</span><span style="color: #ff0000"> </span><span style="color: #0000ff">></</span><span style="color: #800000">disp:column</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />          </span><span style="color: #0000ff"><</span><span style="color: #800000">disp:column </span><span style="color: #ff0000">property</span><span style="color: #0000ff">="pername"</span><span style="color: #ff0000"> title</span><span style="color: #0000ff">="操作人员"</span><span style="color: #ff0000"> </span><span style="color: #0000ff">></</span><span style="color: #800000">disp:column</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />          </span><span style="color: #0000ff"><</span><span style="color: #800000">disp:column </span><span style="color: #ff0000">property</span><span style="color: #0000ff">="opertype"</span><span style="color: #ff0000"> title</span><span style="color: #0000ff">="操作cd"</span><span style="color: #ff0000"> </span><span style="color: #0000ff">></</span><span style="color: #800000">disp:column</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff"></</span><span style="color: #800000">disp:table</span><span style="color: #0000ff">></span><span style="color: #000000"> <br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" /></span></div> </div> <p> </p> <p>name="resultList" 记录集存在session或者request中的键?br /> export="true" 是否昄导出选项<br /> pagesize="100" 每页昄100条数?br /> requestURI="logQueryAction.do"  struts中action的名Uͼ如果记录,可以直接分页<br /> sort="external"  外部排序<br /> id="element"   表格id|用于E序得相关的参数<br /> partialList="true"  分段从数据库中读数据<br /> size="resultSize"  记录的L敎ͼ用于计算总页?/p> <p> </p> <p>struts action:</p> <p> </p> <div style="border-right: windowtext 0.5pt solid; padding-right: 5.4pt; border-top: windowtext 0.5pt solid; padding-left: 5.4pt; background: #e6e6e6; padding-bottom: 4px; border-left: windowtext 0.5pt solid; width: 95%; word-break: break-all; padding-top: 4px; border-bottom: windowtext 0.5pt solid"> <div><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" /><span style="color: #000000">String pageIndexName </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> org.displaytag.util.ParamEncoder(</span><span style="color: #000000">"</span><span style="color: #000000">element</span><span style="color: #000000">"</span><span style="color: #000000">).encodeParameterName(org.displaytag.tags.TableTagParameters.PARAMETER_PAGE);   // |的参数名<br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />        </span><span style="color: #0000ff">int</span><span style="color: #000000"> pageSize </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">100</span><span style="color: #000000">;   //每页昄的条?br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />        </span><span style="color: #0000ff">int</span><span style="color: #000000"> pageIndex </span><span style="color: #000000">=</span><span style="color: #000000"> GenericValidator.isBlankOrNull(request.getParameter(pageIndexName))</span><span style="color: #000000">?</span><span style="color: #000000">0</span><span style="color: #000000">:(Integer.parseInt(request.getParameter(pageIndexName)) </span><span style="color: #000000">-</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000">);  //当前|<br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />String sqlCount </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">"</span><span style="color: #000000">select count(*)  from user_log a </span><span style="color: #000000">"</span><span style="color: #000000">;  //用于l计总记录数的sql语句<br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />        String sql </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">"</span><span style="color: #000000"> select * from (select rownum as rid, t1.* from (select b.pername as pername,to_char(a.operdate,'yyyy-mm-dd hh24:mi:ss') as operdate,</span><span style="color: #000000">"</span><span style="color: #000000"> </span><span style="color: #000000">+</span><span style="color: #000000"><br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />                </span><span style="color: #000000">"</span><span style="color: #000000"> decode(a.opertype,'D','删除','M','修改','其他') as opertype, a.hphm as hphm from user_log a, </span><span style="color: #000000">"</span><span style="color: #000000"> </span><span style="color: #000000">+</span><span style="color: #000000"><br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />                </span><span style="color: #000000">"</span><span style="color: #000000"> (select asuser.userid as userid,nvl(asempmsg.pername,asuser.loginname) as pername from asuser,ASEMPMSG where asuser.perid=ASEMPMSG.perid(+)) b</span><span style="color: #000000">"</span><span style="color: #000000"> </span><span style="color: #000000">+</span><span style="color: #000000"><br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />                </span><span style="color: #000000">"</span><span style="color: #000000"> where a.userid=b.userid </span><span style="color: #000000">"</span><span style="color: #000000">;   //查询语句</span></div> <div><span style="color: #000000">            //构造查询条?br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />        StringBuffer sb </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> StringBuffer();<br /> <img id="_930_1025_Open_Image" onclick="this.style.display='none'; document.getElementById('_930_1025_Open_Text').style.display='none'; document.getElementById('_930_1025_Closed_Image').style.display='inline'; document.getElementById('_930_1025_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="_930_1025_Closed_Image" style="display: none" onclick="this.style.display='none'; document.getElementById('_930_1025_Closed_Text').style.display='none'; document.getElementById('_930_1025_Open_Image').style.display='inline'; document.getElementById('_930_1025_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif" align="top" />        </span><span style="color: #0000ff">if</span><span style="color: #000000">(logQueryForm.getCzrqStart()</span><span style="color: #000000">!=</span><span style="color: #0000ff">null</span><span style="color: #000000"> </span><span style="color: #000000">&&</span><span style="color: #000000"> </span><span style="color: #000000">!</span><span style="color: #000000">""</span><span style="color: #000000">.equals(logQueryForm.getCzrqStart()))</span><span id="_930_1025_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff">...</span><span id="_930_1025_Open_Text"><span style="color: #000000">{<br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />            sb.append(</span><span style="color: #000000">"</span><span style="color: #000000"> and a.operdate > to_date('</span><span style="color: #000000">"</span><span style="color: #000000">+</span><span style="color: #000000">logQueryForm.getCzrqStart()</span><span style="color: #000000">+</span><span style="color: #000000">"</span><span style="color: #000000">','yyyy-mm-dd')</span><span style="color: #000000">"</span><span style="color: #000000">);<br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />        }</span></span><span style="color: #000000"><br /> <img id="_1105_1199_Open_Image" onclick="this.style.display='none'; document.getElementById('_1105_1199_Open_Text').style.display='none'; document.getElementById('_1105_1199_Closed_Image').style.display='inline'; document.getElementById('_1105_1199_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="_1105_1199_Closed_Image" style="display: none" onclick="this.style.display='none'; document.getElementById('_1105_1199_Closed_Text').style.display='none'; document.getElementById('_1105_1199_Open_Image').style.display='inline'; document.getElementById('_1105_1199_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif" align="top" />        </span><span style="color: #0000ff">if</span><span style="color: #000000">(logQueryForm.getCzrqEnd()</span><span style="color: #000000">!=</span><span style="color: #0000ff">null</span><span style="color: #000000"> </span><span style="color: #000000">&&</span><span style="color: #000000"> </span><span style="color: #000000">!</span><span style="color: #000000">""</span><span style="color: #000000">.equals(logQueryForm.getCzrqEnd()))</span><span id="_1105_1199_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff">...</span><span id="_1105_1199_Open_Text"><span style="color: #000000">{<br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />            sb.append(</span><span style="color: #000000">"</span><span style="color: #000000"> and a.operdate <= to_date('</span><span style="color: #000000">"</span><span style="color: #000000">+</span><span style="color: #000000">logQueryForm.getCzrqEnd()</span><span style="color: #000000">+</span><span style="color: #000000">"</span><span style="color: #000000">','yyyy-mm-dd')</span><span style="color: #000000">"</span><span style="color: #000000">);<br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />        }</span></span><span style="color: #000000"><br /> <img id="_1273_1341_Open_Image" onclick="this.style.display='none'; document.getElementById('_1273_1341_Open_Text').style.display='none'; document.getElementById('_1273_1341_Closed_Image').style.display='inline'; document.getElementById('_1273_1341_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="_1273_1341_Closed_Image" style="display: none" onclick="this.style.display='none'; document.getElementById('_1273_1341_Closed_Text').style.display='none'; document.getElementById('_1273_1341_Open_Image').style.display='inline'; document.getElementById('_1273_1341_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif" align="top" />        </span><span style="color: #0000ff">if</span><span style="color: #000000">(logQueryForm.getCzlx()</span><span style="color: #000000">!=</span><span style="color: #0000ff">null</span><span style="color: #000000"> </span><span style="color: #000000">&&</span><span style="color: #000000"> </span><span style="color: #000000">!</span><span style="color: #000000">""</span><span style="color: #000000">.equals(logQueryForm.getCzlx()))</span><span id="_1273_1341_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff">...</span><span id="_1273_1341_Open_Text"><span style="color: #000000">{<br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />            sb.append(</span><span style="color: #000000">"</span><span style="color: #000000"> and a.opertype = '</span><span style="color: #000000">"</span><span style="color: #000000">+</span><span style="color: #000000">logQueryForm.getCzlx()</span><span style="color: #000000">+</span><span style="color: #000000">"</span><span style="color: #000000">'</span><span style="color: #000000">"</span><span style="color: #000000">);<br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />        }</span></span><span style="color: #000000"><br /> <img id="_1415_1481_Open_Image" onclick="this.style.display='none'; document.getElementById('_1415_1481_Open_Text').style.display='none'; document.getElementById('_1415_1481_Closed_Image').style.display='inline'; document.getElementById('_1415_1481_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="_1415_1481_Closed_Image" style="display: none" onclick="this.style.display='none'; document.getElementById('_1415_1481_Closed_Text').style.display='none'; document.getElementById('_1415_1481_Open_Image').style.display='inline'; document.getElementById('_1415_1481_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif" align="top" />        </span><span style="color: #0000ff">if</span><span style="color: #000000">(logQueryForm.getCzry()</span><span style="color: #000000">!=</span><span style="color: #0000ff">null</span><span style="color: #000000"> </span><span style="color: #000000">&&</span><span style="color: #000000"> </span><span style="color: #000000">!</span><span style="color: #000000">""</span><span style="color: #000000">.equals(logQueryForm.getCzry()))</span><span id="_1415_1481_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff">...</span><span id="_1415_1481_Open_Text"><span style="color: #000000">{<br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />            sb.append(</span><span style="color: #000000">"</span><span style="color: #000000"> and a.userid = '</span><span style="color: #000000">"</span><span style="color: #000000">+</span><span style="color: #000000">logQueryForm.getCzry()</span><span style="color: #000000">+</span><span style="color: #000000">"</span><span style="color: #000000">'</span><span style="color: #000000">"</span><span style="color: #000000">);<br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />        }</span></span><span style="color: #000000"><br /> <img id="_1555_1624_Open_Image" onclick="this.style.display='none'; document.getElementById('_1555_1624_Open_Text').style.display='none'; document.getElementById('_1555_1624_Closed_Image').style.display='inline'; document.getElementById('_1555_1624_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="_1555_1624_Closed_Image" style="display: none" onclick="this.style.display='none'; document.getElementById('_1555_1624_Closed_Text').style.display='none'; document.getElementById('_1555_1624_Open_Image').style.display='inline'; document.getElementById('_1555_1624_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif" align="top" />     </span><span style="color: #000000"><br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />        sqlCount </span><span style="color: #000000">+=</span><span style="color: #000000"> sb.toString();<br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />        sql </span><span style="color: #000000">+=</span><span style="color: #000000"> sb.toString()</span><span style="color: #000000">+</span><span style="color: #000000">"</span><span style="color: #000000"> order by a.operdate desc) t1 where rownum<=</span><span style="color: #000000">"</span><span style="color: #000000"><br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />                        </span><span style="color: #000000">+</span><span style="color: #000000"> (pageIndex </span><span style="color: #000000">+</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000">) </span><span style="color: #000000">*</span><span style="color: #000000"> pageSize </span><span style="color: #000000">+</span><span style="color: #000000"> </span><span style="color: #000000">"</span><span style="color: #000000"> ) t2 where t2.rid></span><span style="color: #000000">"</span><span style="color: #000000">+</span><span style="color: #000000"> pageIndex </span><span style="color: #000000">*</span><span style="color: #000000"> pageSize;  //分页d语句<br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />        <br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />        </span><span style="color: #008000">//</span><span style="color: #008000">System.out.println(sb.toString());</span><span style="color: #008000"><br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" /></span><span style="color: #000000">        DBBean db </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> DBBean();<br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />        ResultSet rs </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">null</span><span style="color: #000000">;<br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />        PreparedStatement prep </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">null</span><span style="color: #000000">;<br /> <img id="_1938_2211_Open_Image" onclick="this.style.display='none'; document.getElementById('_1938_2211_Open_Text').style.display='none'; document.getElementById('_1938_2211_Closed_Image').style.display='inline'; document.getElementById('_1938_2211_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="_1938_2211_Closed_Image" style="display: none" onclick="this.style.display='none'; document.getElementById('_1938_2211_Closed_Text').style.display='none'; document.getElementById('_1938_2211_Open_Image').style.display='inline'; document.getElementById('_1938_2211_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif" align="top" />        </span><span style="color: #0000ff">try</span><span id="_1938_2211_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff">...</span><span id="_1938_2211_Open_Text"><span style="color: #000000">{<br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />            List resultList </span><span style="color: #000000">=</span><span style="color: #000000"> db.getResultList(sql);   //ResultSet保存在List里返?br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />            request.setAttribute(</span><span style="color: #000000">"</span><span style="color: #000000">resultList</span><span style="color: #000000">"</span><span style="color: #000000">,resultList);  //把结果存入request<br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />            prep </span><span style="color: #000000">=</span><span style="color: #000000"> db.getConnection().prepareStatement(sqlCount);    <br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />            rs </span><span style="color: #000000">=</span><span style="color: #000000"> prep.executeQuery();<br /> <img id="_2136_2207_Open_Image" onclick="this.style.display='none'; document.getElementById('_2136_2207_Open_Text').style.display='none'; document.getElementById('_2136_2207_Closed_Image').style.display='inline'; document.getElementById('_2136_2207_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="_2136_2207_Closed_Image" style="display: none" onclick="this.style.display='none'; document.getElementById('_2136_2207_Closed_Text').style.display='none'; document.getElementById('_2136_2207_Open_Image').style.display='inline'; document.getElementById('_2136_2207_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span><span style="color: #0000ff">if</span><span style="color: #000000">(rs.next())</span><span id="_2136_2207_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff">...</span><span id="_2136_2207_Open_Text"><span style="color: #000000">{<br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />                request.setAttribute(</span><span style="color: #000000">"</span><span style="color: #000000">resultSize</span><span style="color: #000000">"</span><span style="color: #000000">,</span><span style="color: #0000ff">new</span><span style="color: #000000"> Integer(rs.getInt(</span><span style="color: #000000">1</span><span style="color: #000000">)));     //总记录数保存成Intger实例保存在request?br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span></span><span style="color: #000000"><br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />        }</span></span><span style="color: #000000"><br /> <img id="_2234_2263_Open_Image" onclick="this.style.display='none'; document.getElementById('_2234_2263_Open_Text').style.display='none'; document.getElementById('_2234_2263_Closed_Image').style.display='inline'; document.getElementById('_2234_2263_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="_2234_2263_Closed_Image" style="display: none" onclick="this.style.display='none'; document.getElementById('_2234_2263_Closed_Text').style.display='none'; document.getElementById('_2234_2263_Open_Image').style.display='inline'; document.getElementById('_2234_2263_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif" align="top" />        </span><span style="color: #0000ff">catch</span><span style="color: #000000">(Exception ex)</span><span id="_2234_2263_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff">...</span><span id="_2234_2263_Open_Text"><span style="color: #000000">{<br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />            ex.printStackTrace();<br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />        }</span></span><span style="color: #000000"><br /> <img id="_2274_2327_Open_Image" onclick="this.style.display='none'; document.getElementById('_2274_2327_Open_Text').style.display='none'; document.getElementById('_2274_2327_Closed_Image').style.display='inline'; document.getElementById('_2274_2327_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="_2274_2327_Closed_Image" style="display: none" onclick="this.style.display='none'; document.getElementById('_2274_2327_Closed_Text').style.display='none'; document.getElementById('_2274_2327_Open_Image').style.display='inline'; document.getElementById('_2274_2327_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif" align="top" />        </span><span style="color: #0000ff">finally</span><span id="_2274_2327_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff">...</span><span id="_2274_2327_Open_Text"><span style="color: #000000">{<br /> <img id="_2291_2322_Open_Image" onclick="this.style.display='none'; document.getElementById('_2291_2322_Open_Text').style.display='none'; document.getElementById('_2291_2322_Closed_Image').style.display='inline'; document.getElementById('_2291_2322_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="_2291_2322_Closed_Image" style="display: none" onclick="this.style.display='none'; document.getElementById('_2291_2322_Closed_Text').style.display='none'; document.getElementById('_2291_2322_Open_Image').style.display='inline'; document.getElementById('_2291_2322_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span><span style="color: #0000ff">if</span><span style="color: #000000">(db</span><span style="color: #000000">!=</span><span style="color: #0000ff">null</span><span style="color: #000000">)</span><span id="_2291_2322_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff">...</span><span id="_2291_2322_Open_Text"><span style="color: #000000">{<br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />                db.closeConnection();    //关闭q接<br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span></span><span style="color: #000000"> <br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />        }</span></span></div> </div> <p> </p> <p>其中的页面导航是英文的,只要修改org.displaytag.properties.TableTag.properties配置文g可以把英文Ҏ中文。同时还可以指定导出文g的类型以及文件名?/p> <div style="border-right: windowtext 0.5pt solid; padding-right: 5.4pt; border-top: windowtext 0.5pt solid; padding-left: 5.4pt; background: #e6e6e6; padding-bottom: 4px; border-left: windowtext 0.5pt solid; width: 95%; word-break: break-all; padding-top: 4px; border-bottom: windowtext 0.5pt solid"> <div><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" /><span style="color: #000000">export.excel</span><span style="color: #000000">=</span><span style="color: #000000">true<br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />export.excel.label</span><span style="color: #000000">=</span><span style="color: #000000"><span class</span><span style="color: #000000">=</span><span style="color: #000000">"</span><span style="color: #000000">export excel</span><span style="color: #000000">"</span><span style="color: #000000">>Excel </span><br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />export.excel.include_header</span><span style="color: #000000">=</span><span style="color: #000000">true<br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />export.excel.filename</span><span style="color: #000000">=</span><span style="color: #000000">export.xls</span></div> </div> <p>如果不指定文件名Q在点击导出excel的时候,׃在ieH口中打开excel文g。很烦hQ?br /> 指定文g名后可以选择保存和打开了?/p> <div align="center"><script type="text/javascript"><!--google_ad_client = "pub-9648238652058580"; google_ad_width="468;google_ad_height" = 60; google_ad_format="468x60_as_rimg" ; google_cpa_choice="CAAQiYaYhAIaCJ2wcuQYTrQ_KOm293M" ; google_ad_channel="" ;//--></script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script></div> <br /> <br /> <p id="TBPingURL">Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1076047</p> <img src ="http://www.aygfsteel.com/keweibo/aggbug/145313.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/keweibo/" target="_blank">KE</a> 2007-09-15 10:32 <a href="http://www.aygfsteel.com/keweibo/articles/145313.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Displaytag1.1支持在外部实现大数据量分?/title><link>http://www.aygfsteel.com/keweibo/articles/145310.html</link><dc:creator>KE</dc:creator><author>KE</author><pubDate>Sat, 15 Sep 2007 02:21:00 GMT</pubDate><guid>http://www.aygfsteel.com/keweibo/articles/145310.html</guid><wfw:comment>http://www.aygfsteel.com/keweibo/comments/145310.html</wfw:comment><comments>http://www.aygfsteel.com/keweibo/articles/145310.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/keweibo/comments/commentRss/145310.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/keweibo/services/trackbacks/145310.html</trackback:ping><description><![CDATA[     摘要: Displaytag1.1支持在外部实现大数据量分c主要有两种方式实现Q? Displaytag 1.1 offers two alternative ways for working with partial lists: the first one uses the valuelist pattern, and requires that the object tha...  <a href='http://www.aygfsteel.com/keweibo/articles/145310.html'>阅读全文</a><img src ="http://www.aygfsteel.com/keweibo/aggbug/145310.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/keweibo/" target="_blank">KE</a> 2007-09-15 10:21 <a href="http://www.aygfsteel.com/keweibo/articles/145310.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Display Taghttp://www.aygfsteel.com/keweibo/articles/144578.htmlKEKEWed, 12 Sep 2007 10:37:00 GMThttp://www.aygfsteel.com/keweibo/articles/144578.htmlhttp://www.aygfsteel.com/keweibo/comments/144578.htmlhttp://www.aygfsteel.com/keweibo/articles/144578.html#Feedback0http://www.aygfsteel.com/keweibo/comments/commentRss/144578.htmlhttp://www.aygfsteel.com/keweibo/services/trackbacks/144578.html     Display Tag Lib是一个标{ֺQ用来处理jsp|页上的TableQ功能非常强Q可以对的Tableq行分页、数据导出、分l、对列排序等{,反正我在做项目时需要的功能它都l我提供了,而且使用h非常的方ѝ能够大大减代码量?br />     介个是Display Tag的官方网?a >http://displaytag.sourceforge.net?br />
    首先当然是要下蝲它的jar包了Q?a >q里可以下蝲到最新的版本。将jar包放到WEB-INF的lib文g夹下。另外还需要两个辅助包Qapache的commons-lang和standard包,更多的辅助包可以在这?a >下蝲?br />
    在web.xml下添加一个filter
    <filter>
        <filter-name>exportFilter</filter-name>
        <filter-class>org.displaytag.filter.ResponseOverrideFilter</filter-class>
    </filter>

    在jsp面做一个引用:
<%@ taglib uri="http://displaytag.sf.net/el" prefix="display" %>

    首先我们定义一个list
<%
 List test = new ArrayList( 6 );
 test.add( "Test String 1" );
 test.add( "Test String 2" );
 test.add( "Test String 3" );
 test.add( "Test String 4" );
 test.add( "Test String 5" );
 test.add( "Test String 6" );
 request.setAttribute( "test", test );
%>

    当我们想在jsp面上显C个listӞ我们只需要写一句话
    <display:table name="test" />
    display tag会自动生成一个table

    如果list是从控制层抛出来的,name可用EL表达式表C?br />     <display:table name="${test}" />

    q是最单的display tag的用,我们可以l它加上样式{,也可以定义显C的列,下面的table昄复杂一?br /> <display:table name="test" styleClass="list" cellspacing="0" cellpadding="0">
  <display:column property="id" title="ID" class="idcol"/>
  <display:column property="name" />
  <display:column property="email" />
  <display:column property="description" title="Comments"/>
</display:table>

    如果惌l它加个链接也很?下面的代码给name加了q接Qƈ附带id参数Qemail也自动连接到mailto:XXX
<display:table name="test" styleClass="list" cellspacing="0" cellpadding="0">
  <display:column property="id" title="ID" class="idcol"/>
  <display:column property="name" url="detail.jsp" paramId="id" paramProperty="id"/>
  <display:column property="email" autolink="true"/>
  <display:column property="description" title="Comments"/>
</display:table>

下面介绍几个Display最常用的功能,更多功能请参?a >http://displaytag.homeip.net/displaytag-examples-1.1/?br /> 1. 分页
    如果惛_代码分页Q只需在display:table标签中添加一pagesize="每页昄行数"Q如
<display:table name="test" pagesize="10"/>

2. 对列排序
    display tag可对列进行排序,是点击列名Q对该列的数据进行排序。你只需Ҏ要排序的列添?sort="true" OKQ如下面的代码可对前三列q行排序。在display:table中添加defaultsort="列数"Q可默认Ҏ定的列排序?br /> <display:table name="test" styleClass="list" cellspacing="0" cellpadding="0" defaultsort="1">
  <display:column property="id" title="ID" class="idcol" sort="true"/>
  <display:column property="name" url="detail.jsp" paramId="id" paramProperty="id" sort="true"/>
  <display:column property="email" autolink="true" sort="true"/>
  <display:column property="description" title="Comments"/>
</display:table>
   如果table有分,Display Tag默认只对当前进行排序,如果惛_整个list排序Q可以在display:table之间d一D代码:
<display:setProperty name="sort.amount" value="list"/>

3. 导出数据
    在display:table中添加export="true"Q看看会出现什么!Display Tag默认会提供三U数据导出方式:CSV、Excel、XML ?br />     另外Display Tagq可以导ZؓPDF格式Q在http://prdownloads.sourceforge.net/itext/下蝲一个辅助包iText.jarQcopy到lib目录下,然后在display:table之间d一D代码:
<display:setProperty name="export.pdf" value="true"/>Q大功告成?/p>

4. Display Tag的属性设|?br />     前面所说的display:setProperty 是一U改变Display Tag属性的ҎQ但是在每个jsp中都要写太麻烦了?br />     Display Tag中设|了很多默认的属性,它有一个专门的属性文Ӟ是在它的jar包中的displaytag/properties/TableTag.properties
    惌改变它的默认属性,我们可以在WEB-INF\classes下新Z个文件displaytag.propertiesQ仿照TableTag.properties中属性的格式讄需要修改的属性?br />     TableTag.properties中的# messages中设|的是显C在面上的提示信息。默认是英文的,我们可以把它改ؓ中文的。不q这里只能用unicodeQ就是说中文字符必须转换为unicode码,q个可以使用jdk自带的native2ascii.exeq行转换?/p>

5. 其它功能
    DisplayTagq有一些很实用的小功能Q这里提两个。一个是Ҏ据的FormatQ这?.1版本d的新功能Q可以用标{方式格式化时间、数字、字W串。比如日期,在需要格式化的column标签中添加format="{0,date,yyyy-MM-dd}"Q第一个参Cؓ格式化的数据序号Q第二个参数是数据类型,数字为numberQ第三个参数为数据格式?br />     另外一个功能是对table数据的合计功能。在table标签中添?decorator="org.displaytag.decorator.TotalTableDecorator"Q然后在惌q行合计的数据列的column标签中添?total="true"Q该列就可以被计L了。但q个功能有个~点Q不能用在有分页的时候,它只能合计第一늚数据?br />
DisplayTag的不?br />     初次使用DisplayTag的h可能会觉得惊喜,但是用久了会发现很多问题Q最大的问题是对中文的支持不好,比如如果查询条g中有中文Q就无法页Q无法对中文排序Q将中文导出为指定文件时出现q{等。这些问题有时候会让h很郁P有时候逼得你要M改它的源代码。下面是对以上几个问题的解决ҎQ?br />     1. 对于中文无法页、排序,最单的办法是修改Tomcat下的server.xml文g。找到HTTP的Connector标签Q在里面d一URIEncoding="..."Q引号里面的内容取决于你的页面编码,比如可以是GBKQUTF8{。这样上面两个问题就可以解决了?br />     2. 导出为文Ӟ其实q个功能除了中文支持外还有很多其它问题,比如它会Html标签一起导出、只导出昄的内容,但如果对tableq行了decoratorQdecorator后的内容无法导出。如果想要将中文正确导出Q需要修改DisplayTag源代码?br />     下蝲相同版本的源代码Q在org.displaytag.export.ExcelView.java文g中找到getMimeType()ҎQ将此方法修改ؓ return "application/vnd.ms-excel;charset=GB2312";Q修改后导出数据的速度会慢很多Q不q将吧?br />     3. 新版的DisplayTag1.1d了对一ơ取部分数据的支持,相关的标{֌括partialList和sizeQ需要设|partialList="true"和size的大。具体怎么用偶q没研究?/p>

Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=296316



KE 2007-09-12 18:37 发表评论
]]>
jstl标签的?http://www.aygfsteel.com/keweibo/articles/138225.htmlKEKEMon, 20 Aug 2007 12:29:00 GMThttp://www.aygfsteel.com/keweibo/articles/138225.htmlhttp://www.aygfsteel.com/keweibo/comments/138225.htmlhttp://www.aygfsteel.com/keweibo/articles/138225.html#Feedback0http://www.aygfsteel.com/keweibo/comments/commentRss/138225.htmlhttp://www.aygfsteel.com/keweibo/services/trackbacks/138225.htmlJSTL(Java Server Page Standalone Tag Library)

1Q?span>servlet?span>xml配置Q在action引用中一定要加上根目录(/project/servlet/HelloQ?/span>

<servlet>

    <servlet-name>Hello</servlet-name>

    <servlet-class>mypack.Hello</servlet-class>

 </servlet>

 <servlet-mapping>

    <servlet-name>Hello</servlet-name>

    <url-pattern>/servlet/Hello</url-pattern>

 </servlet-mapping>


2
Q?span>JSP2.0新特性:ELQ?span>Expression LanguageQ语aQ只能在标签开始和标签l束之间

Eg:name:${param.name } ${paramValues.habit[0]} ${paramValues.habit[1]}

        <%request.setAttribute("title","book"); %> ${requestScope.title }


3.JSTL(Java Server Page Standalone Tag Library):
本n是一U强标记Q比JSP动作更强


a.
一般用途和条g标签Q?/span>

1.<c:out value="hello" default="ol" escapeXml="false"> body:can not see</c:out>

 2.<c:set scope="page" value="nihao" var="name1"/> <c:out value="${name1}"/>

 3.<jsp:useBean id="User" class="mypack.User"></jsp:useBean>

   <c:set property="name" target="${User}" value="k" > value is default</c:set>

   <c:out value="${User.name}"/> //输出k

 4.<c:set var="count" value="100" scope="page"/> <c:if test="${count>78}">ok </c:if>

 5.<c:remove var="count" scope="page"/>

 6.<c:catch var="e"><%Integer.parseInt("m");%></c:catch> <c:out value="e.message"/>

6.<c:choose>

    <c:when test="${count<=0}"> <font color="bule"> </c:when>

    <c:otherwise> <font color="green">   </c:otherwise> </c:choose>  

     the value count is:<c:out value="${count}"/>



b.
q代循环标签Q?span><jsp:useBean id="test" class="mypack.User"></jsp:useBean>

    <% Collection users_c=new ArrayList();

       for(int i=0;i<3;i++) { test.setName("foo"+i); users_c.add(test); }

       session.setAttribute("attr",users_c); %>//只有在一定范围内才能扑ֈ

 <c:forEach var="each" items="${attr}"> <c:out value="${each.name}"/></c:forEach>

<c:forEach var="s" begin="50" end="60" step="2"><c:out value="${s}"/></c:forEach>



c.URL
标签Q?span><c:import url="test1.jsp" charEncoding="gb2312"></c:import>

   <c:url value="test2.jsp" var="nx" scope="request">//url重定?/span>

   <c:param name="user" value="liming"></c:param> </c:url> <c:redirect url="${nx}"/>



d:SQL
标签Q?span><sql:setDataSource var="db1"    driver="com.mysql.jdbc.Driver"

url="jdbc:mysql://localhost:3306/mydb" user="root" password="root" scope="session" />

    <sql:query var="query" dataSource="${db1}"   sql="SELECT * FROM mytable"/>

    <table border="1"> <c:forEach var="row" items="${query.rows}">//要P代的集合

     <tr> <td>name:<c:out value="${row.name}"/></tr></c:forEach> </table>  

    <sql:update dataSource="${db1}" sql="update mytable set age='22' where id=1" var="update1"/>

//
要导?span><%@ taglib prefix="sql|c "uri="http://*/sql|core"%>



KE 2007-08-20 20:29 发表评论
]]>
վ֩ģ壺 | | ˶| | Ҫ| ׿| | | ں| | | ̨ʡ| | | | 㶫ʡ| | ˴| ƽ| | | | ɽ| ʯ| | | ͭ| | | | ˼| | | ֳ| ¸| ˳| | | ׷| ʩ| Թ|