锘??xml version="1.0" encoding="utf-8" standalone="yes"?>久久久无码精品亚洲日韩蜜臀浪潮,久久精品国产亚洲沈樵,亚洲香蕉免费有线视频http://m.tkk7.com/flustar/category/18661.html寮鍙戣漿浜嗛攢鍞紝榪樿兘鐢遍攢鍞仛鍥炲紑鍙戝悧錛?/description>zh-cnSat, 12 Sep 2009 16:53:45 GMTSat, 12 Sep 2009 16:53:45 GMT60Struts2+spring2+hibernate3鏁村悎鏂規(guī)http://m.tkk7.com/flustar/archive/2007/12/26/ssha.htmlflustarflustarTue, 25 Dec 2007 17:11:00 GMThttp://m.tkk7.com/flustar/archive/2007/12/26/ssha.htmlhttp://m.tkk7.com/flustar/comments/170431.htmlhttp://m.tkk7.com/flustar/archive/2007/12/26/ssha.html#Feedback36http://m.tkk7.com/flustar/comments/commentRss/170431.htmlhttp://m.tkk7.com/flustar/services/trackbacks/170431.html闃呰鍏ㄦ枃

flustar 2007-12-26 01:11 鍙戣〃璇勮
]]>
鍩轟簬spring+dwr+xml鏃犲埛鏂版姇紲?璋冩煡)緋葷粺http://m.tkk7.com/flustar/archive/2007/11/19/spring_dwr_xml.htmlflustarflustarMon, 19 Nov 2007 10:04:00 GMThttp://m.tkk7.com/flustar/archive/2007/11/19/spring_dwr_xml.htmlhttp://m.tkk7.com/flustar/comments/161691.htmlhttp://m.tkk7.com/flustar/archive/2007/11/19/spring_dwr_xml.html#Feedback0http://m.tkk7.com/flustar/comments/commentRss/161691.htmlhttp://m.tkk7.com/flustar/services/trackbacks/161691.html涓銆佸緩绔媥ml鐨勬暟鎹粨鏋勶紝鏂囦歡鍚嶄負(fù)錛歷ote.xml錛屽唴瀹瑰涓嬶細(xì)

<?xml version="1.0" encoding="UTF-8"?>

<votes voteTotalCount="0">

    <vote voteId="1" name="c璇█ " voteCount="0" percentum="0" />

    <vote voteId="2" name="c++" voteCount="0" percentum="0" />

    <vote voteId="3" name="java" voteCount="0" percentum="0" />

    <vote voteId="4" name="姹囩紪璇█" voteCount="0" percentum="0" />

 </votes>

鍦ㄤ綘鐨剋eb搴旂敤鐨勬牴鐩綍寤虹珛xml鏂囦歡澶癸紝灝嗗叾鎷瘋礉鍒拌鐩綍涓嬨?/p>

浜屻佸緩绔媥ml瀵瑰簲鐨刡ean

/**

 * @author flustar

 * @version 鍒涘緩鏃墮棿錛欽ul 11, 2007 5:17:53 PM

 * 綾昏鏄?/p>

 */

……………………………………………………………………….

……………………………………………………………………….

public class VoteBean {

    private String voteId;

   private String name;

    private String voteCount;

    private String voteTotalCount;

    private String percentum;

    public VoteBean() {

      

    }

    public String getPercentum() {

       return percentum;

    }

    public void setPercentum(String percentum) {

       this.percentum = percentum;

    }

    public String getVoteId() {

       return voteId;

    }

 

    public void setVoteId(String voteId) {

       this.voteId = voteId;

    }

    public String getName() {

       return name;

    }

    public void setName(String name) {

       this.name = name;

    }

    public String getVoteCount() {

       return voteCount;

    }

 

    public void setVoteCount(String voteCount) {

       this.voteCount = voteCount;

    }

}

涓夈佸緩绔嬪鐞嗗叿浣撻昏緫鐨剆ervice

package com.flustar.service;

import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.text.NumberFormat;

import java.util.ArrayList;

import java.util.Iterator;

import java.util.List;

import org.jdom.Attribute;

import org.jdom.Document;

import org.jdom.Element;

import org.jdom.input.SAXBuilder;

import org.jdom.output.Format;

import org.jdom.output.XMLOutputter;

import org.jdom.xpath.XPath;

import com.flustar.web.beans.VoteBean;

import com.flustar.web.config.ContextConfig;

public class VoteService {

       private Element root, vote;

       private Document doc;

      private Attribute voteTotalCount;

       private VoteBean voteBean;

       private List<VoteBean> voteBeanList;

       private String path = ContextConfig.getContextPath()

                     + "/xml/vote.xml";

       public void buildDoc() throws Exception {

              FileInputStream fi = null;

              fi = new FileInputStream(path);

              SAXBuilder sb = new SAXBuilder();

              doc = sb.build(fi);

       }

       public void formatDoc() throws Exception {

              Format format = Format.getCompactFormat();

              format.setEncoding("UTF-8");// 璁劇疆xml鏂囦歡鐨勫瓧絎︿負(fù)UTF-8

              format.setIndent("    ");// 璁劇疆xml鏂囦歡緙╄繘涓?涓┖鏍?/p>

              XMLOutputter xmlOut = new XMLOutputter(format);

              xmlOut.output(doc, new FileOutputStream(path));

       }

 

       public String floatToPercentum(Double doubleNum) {

              NumberFormat numberFormat = NumberFormat.getPercentInstance();

              numberFormat.setMinimumFractionDigits(2);

              // numberFormat.setMaximumIntegerDigits(2);

              String str = numberFormat.format(doubleNum);

              //System.out.println(str);

              return str;

       }

 

       public void updateVoteCount(String voteId) throws Exception {

              buildDoc();

              root = doc.getRootElement();

              vote = (Element) XPath.selectSingleNode(root, "http://vote[@voteId='"

                            + voteId + "']");

              int voteCount = Integer.parseInt(vote.getAttributeValue("voteCount")) + 1;

              //System.out.println(voteCount);

              vote.setAttribute("voteCount", String.valueOf(voteCount));

              int totalCount = Integer.parseInt(root

                            .getAttributeValue("voteTotalCount")) + 1;

              voteTotalCount = new Attribute("voteTotalCount", String

                            .valueOf(totalCount));

              root.setAttribute(voteTotalCount);

              System.out.println(totalCount);

              formatDoc();

              updateAllVoteCount();//鏇存柊鎵鏈夌殑鐧懼垎姣?/p>

 

       }

    public void updateAllVoteCount()throws Exception{

           buildDoc();

           root=doc.getRootElement();

           int totalCount = Integer.parseInt(root

                            .getAttributeValue("voteTotalCount"));

           List voteList=XPath.selectNodes(root,"/votes/vote");

           for(int i=0;i<voteList.size();i++){

                  vote=(Element)voteList.get(i);

                  int voteCount = Integer.parseInt(vote.getAttributeValue("voteCount"));

                  System.out.println(voteCount);

                  vote.setAttribute("voteCount", String.valueOf(voteCount));

                  vote.setAttribute("percentum", floatToPercentum(1.0 * voteCount

                                / totalCount));

           }

           formatDoc();

    }

       public List getAllVote() throws Exception {

              buildDoc();

              voteBeanList = new ArrayList();

              root = doc.getRootElement();

              String totalCount = root.getAttributeValue("voteTotalCount");

              List voteList = root.getChildren();

              Iterator i = voteList.iterator();

 

              while (i.hasNext()) {

                     voteBean = new VoteBean();

                     voteBean.setVoteTotalCount(totalCount);

                     vote = (Element) i.next();

                     String name = vote.getAttributeValue("name");

                     String voteCount = vote.getAttributeValue("voteCount");

                     String percentum = vote.getAttributeValue("percentum");

 

                     voteBean.setName(name);

                     voteBean.setVoteCount(voteCount);

                     voteBean.setPercentum(percentum);

                     voteBeanList.add(voteBean);

              }

              return voteBeanList;

       }

 

}

 

    public String getVoteTotalCount() {

       return voteTotalCount;

    }

 

    public void setVoteTotalCount(String voteTotalCount) {

       this.voteTotalCount = voteTotalCount;

    }

}

 

鍥涖佽幏鍙栦笂涓嬫枃璺緞鐨刲istener

package com.flustar.web.listener;

import javax.servlet.ServletContextEvent;

import javax.servlet.ServletContextListener;

import com.flustar.web.config.ContextConfig;

public class ConfigLoadContextListener implements  ServletContextListener{

    public void contextDestroyed(ServletContextEvent arg0) {

       // TODO Auto-generated method stub

           }

    public void contextInitialized(ServletContextEvent contextEvent) {

       // TODO Auto-generated method stub

              String contextPath = contextEvent.getServletContext().getRealPath("/");

       ContextConfig.setContextPath(contextPath);

           }

}

………………………………………………………..

……………………………………………………………

 

public class ContextConfig {

    private static String contextPath;

 

    public static String getContextPath() {

       return contextPath;

    }

 

    public static void setContextPath(String contextPath) {

       ContextConfig.contextPath = contextPath;

    }

……………………………………………………………………

………………………………………………………………..

}

浜斻佸湪applicationContext-service.xml涓敞鍐孷oteService

<bean name="voteService" class="com.flustar.service.imp.VoteService"/>

鍏佹敞鍐寈ml錛屽湪浣犵殑web搴旂敤鐨刉EB-INFO鐩綍涓嬪緩绔媋pplicationContext-dwr.xml鏂囦歡錛屽唴瀹逛負(fù)錛?/p>

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN" "http://getahead.org/dwr/dwr20.dtd">

<dwr>

    <allow>

      <create  creator="spring" javascript="VoteService" >

         <param name="beanName" value="voteService"></param>

         <include method="updateVoteCount"/>

         <include method="getAllVote"/>

      </create>

      <convert converter="bean"  match="com.flustar.web.beans.VoteBean" />

           </allow>

</dwr>

 

涓冦佷慨鏀箇eb.xml

<?xml version="1.0" encoding="UTF-8"?>

<web-app 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 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"

    version="2.4">

    …………………………………………………………………………………………………………………………

………………………………………………………………………………………………………………………………..

    <context-param>

       <param-name>contextConfigLocation</param-name>

       <param-value>

…………………………………..

       /WEB-INF/classes/applicationContext-service.xml

</param-value>

    </context-param>

 …………………………………………………………………………………………………………………………………………….     <listener-class>com.flustar.web.listener.ConfigLoadContextListener</listener-class>

    …………………………………………………………………………………………………………………………………………….   

  <servlet>

    <servlet-name>dwr-invoker</servlet-name>

    <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>

    <init-param>

      <param-name>debug</param-name>

      <param-value>true</param-value>

    </init-param>

  </servlet>

 

  <servlet-mapping>

    <servlet-name>dwr-invoker</servlet-name>

    <url-pattern>/dwr/*</url-pattern>

  </servlet-mapping> 

…………………………………………………………………………………………………………………………………………….   

</web-app>

鍏乯sp欏甸潰

1)

<%@ page contentType="text/html; charset=gbk" language="java" import="java.sql.*" errorPage="" %>

<html>

<head>

<title>鎶曠エ緋葷粺</title>

       <script type='text/javascript' src='dwr/engine.js'> </script>

        <script type='text/javascript' src='dwr/util.js'> </script>

        <script type='text/javascript' src='dwr/interface/VoteService.js'> </script>

       <script type='text/javascript'>

function vote(){

       

     var   obj=document.getElementsByName('radio'); 

    

         if   (obj!=null){ 

         var j=0;

           for   (var   i=0;i<obj.length;i++){ 

             if   (obj[i].checked)  

              {  

               

                   VoteService.updateVoteCount(obj[i].value);

                   alert("鎶曠エ鎴愬姛!");

                  obj[i].checked=false;

                  break;

               }

              }

               j=j+1;

             

          }

         if(j==obj.length){

                alert("璇烽変腑鍏朵腑鐨勪竴欏癸紝鍐嶆姇紲?");

               }

          

      }

   

    }

  function showwin(){

    window.open('voteresult.htm','voteresult','height=400, width=400, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');

   }

 }

</script>

</head>

<body>

<div >

    <h1 >

       浣犱嬌鐢ㄦ渶澶氱殑涓闂ㄨ璦鏄紵

    </h1>

</div>

<div>

<div>

        <span>     <h1><input type="radio" name="radio" id="radio" value="1" />

       C璇█</h1>

        </span>

       <span> <h1 ><input type="radio" name="radio" id="radio" value="2" />c++ </h1> </span>

       <span ><h1 ><input type="radio" name="radio" id="radio" value="3" />java </h1> </span>

       <span><h1 ><input type="radio" name="radio" id="radio" value="4"/>姹囩紪璇█</h1> </span>

</div>

</div>

<div id="toupiao"><input class="btn" type="button" value="鎶曠エ" onClick="vote()" /><input class="btn" type="button" value="鏌ョ湅" onClick="showwin()"/></div>

</body>

</html>

2)

<html>

<head>

<meta http-equiv="content-type" content="text/html; charset=gb2312">

<title>鎶曠エ緇撴灉</title>

       <script type='text/javascript' src='dwr/engine.js'> </script>

        <script type='text/javascript' src='dwr/util.js'> </script>

        <script type='text/javascript' src='dwr/interface/VoteService.js'> </script>

        <script type='text/javascript' >

function showresult(){

             VoteService.getAllVote(function(data){

             document.getElementById("totalCount").innerHTML=data[0].voteTotalCount;

             for(var i=0;i<data.length;i++){

                  var voteBean=data[i];

                  document.getElementById("xuanshou"+i).innerHTML=voteBean.name;

                  document.getElementById("baifenbi"+i).innerHTML=voteBean.percentum;

                  document.getElementById("piaoshu"+i).innerHTML=voteBean.voteCount;

                  document.getElementById("img"+i).width=voteBean.voteCount/data[0].voteTotalCount*310;

                                   

      }

    });

          

}

</script>

</head>

<body onLoad="showresult()">

<div id="voteRs">

<table border="0" cellpadding="0" cellspacing="0">

  <CAPTION valign="top" class="subject">

鎶曠エ緇撴灉

    </CAPTION>

  <tbody>

  <tr >

    <th>璇█</th>

    <th>鐧懼垎姣?lt;/th>

    <th>紲ㄦ暟</th>

  </tr>

  <tr>

    <td><span id="xuanshou0"></span></td>

    <td><span id="baifenbi0"></span><img id="img0" src='images/voteprogress.gif' width=0 height=10></td>

    <td><span id="piaoshu0"></span></td>

  </tr>

  <tr>

    <td><span id="xuanshou1"></span></td>

    <td><span id="baifenbi1"></span><img id="img1" src='images/voteprogress.gif' width=0 height=10></td>

    <td><span id="piaoshu1"></span></td>

  </tr>

  <tr>

    <td><span id="xuanshou2"></span></td>

    <td><span id="baifenbi2"></span><img id="img2" src='images/voteprogress.gif' width=0 height=10></td>

    <td><span id="piaoshu2"></span></td>

  </tr>

   <tr>

    <td><span id="xuanshou3"></span></td>

    <td><span id="baifenbi3"></span><img id="img3" src='images/voteprogress.gif' width=0 height=10></td>

    <td><span id="piaoshu3"></span></td>

  </tr>

 

  </tbody>

</table>

鍏?lt;span id="totalCount"></span>鏉℃姇紲?lt;br/>

[<span onClick="javascript:window.close();">鍏抽棴紿楀彛</span>]

</div>

</body>

</html>

 



flustar 2007-11-19 18:04 鍙戣〃璇勮
]]>
鍒嗕韓涓涓猻pring+hibernate鐨勯氱敤鍒嗛〉綾?/title><link>http://m.tkk7.com/flustar/archive/2007/11/13/160142.html</link><dc:creator>flustar</dc:creator><author>flustar</author><pubDate>Tue, 13 Nov 2007 02:50:00 GMT</pubDate><guid>http://m.tkk7.com/flustar/archive/2007/11/13/160142.html</guid><wfw:comment>http://m.tkk7.com/flustar/comments/160142.html</wfw:comment><comments>http://m.tkk7.com/flustar/archive/2007/11/13/160142.html#Feedback</comments><slash:comments>5</slash:comments><wfw:commentRss>http://m.tkk7.com/flustar/comments/commentRss/160142.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/flustar/services/trackbacks/160142.html</trackback:ping><description><![CDATA[<span style="font-size: 10pt">    鏃墮棿榪囧緱鐪熷揩錛屽凡緇忓崐騫存病鏈夋洿鏂拌嚜宸辯殑鍗氬浜嗐?nbsp;   濂戒簡錛岃█褰掓浼犮傚ぇ瀹墮兘鐭ラ亾緗戜笂騫夸負(fù)嫻佷紶鐨勪竴涓垎欏電被鏄細(xì)PaginationSupport.java鍏舵簮浠g爜濡備笅錛?br />      <p>public class PaginationSupport{</p> <p> public final static int PAGESIZE = 30;</p> <p> private int pageSize = PAGESIZE;</p> <p> private List items;</p> <p> private int totalCount;</p> <p> private int[] indexes = new int[0];</p> <p> private int startIndex = 0;</p> <p> public PaginationSupport(List items, int totalCount) {<br />   setPageSize(PAGESIZE);<br />   setTotalCount(totalCount);<br />   setItems(items);<br />   setStartIndex(0);<br />  }</p> <p> public PaginationSupport(List items, int totalCount, int startIndex) {<br />   setPageSize(PAGESIZE);<br />   setTotalCount(totalCount);<br />   setItems(items);<br />   setStartIndex(startIndex);<br />  }</p> <p> public PaginationSupport(List items, int totalCount, int pageSize,<br />    int startIndex) {<br />   setPageSize(pageSize);<br />   setTotalCount(totalCount);<br />   setItems(items);<br />   setStartIndex(startIndex);<br />  }</p> <p> public List getItems() {<br />   return items;<br />  }</p> <p> public void setItems(List items) {<br />   this.items = items;<br />  }</p> <p> public int getPageSize() {<br />   return pageSize;<br />  }</p> <p> public void setPageSize(int pageSize) {<br />   this.pageSize = pageSize;<br />  }</p> <p> public int getTotalCount() {<br />   return totalCount;<br />  }</p> <p> public void setTotalCount(int totalCount) {<br />   if (totalCount > 0) {<br />    this.totalCount = totalCount;<br />    int count = totalCount / pageSize;<br />    if (totalCount % pageSize > 0)<br />     count++;<br />    indexes = new int[count];<br />    for (int i = 0; i < count; i++) {<br />     indexes[i] = pageSize * i;<br />    }<br />   } else {<br />    this.totalCount = 0;<br />   }<br />  }</p> <p> public int[] getIndexes() {<br />   return indexes;<br />  }</p> <p> public void setIndexes(int[] indexes) {<br />   this.indexes = indexes;<br />  }</p> <p> public int getStartIndex() {<br />   return startIndex;<br />  }</p> <p> public void setStartIndex(int startIndex) {<br />   if (totalCount <= 0)<br />    this.startIndex = 0;<br />   else if (startIndex >= totalCount)<br />    this.startIndex = indexes[indexes.length - 1];<br />   else if (startIndex < 0)<br />    this.startIndex = 0;<br />   else {<br />    this.startIndex = indexes[startIndex / pageSize];<br />   }<br />  }</p> <p> public int getNextIndex() {<br />   int nextIndex = getStartIndex() + pageSize;<br />   if (nextIndex >= totalCount)<br />    return getStartIndex();<br />   else<br />    return nextIndex;<br />  }</p> <p> public int getPreviousIndex() {<br />   int previousIndex = getStartIndex() - pageSize;<br />   if (previousIndex < 0)<br />    return 0;<br />   else<br />    return previousIndex;<br />  }</p> <p> public int getPageCount() {<br />   int count = totalCount / pageSize;<br />   if (totalCount % pageSize > 0)<br />    count++;<br />   return count;<br />  }</p> <p> public int getCurentPageNum() {<br />   return getStartIndex() / pageSize + 1;<br />  }</p> <p>}<br /> 鍦ㄨ繖涓垎欏電被涓瀹氫簡姣忛〉瑕佹樉紺虹殑璁板綍鏁頒互鍙婂紑濮嬬儲寮曪紝濡傛灉鐢ㄦ櫘閫氱殑jsp鏉ュ彇榪欎釜鍒嗛〉綾葷殑鏁版嵁榪樺彲浠ワ紝浣嗘槸浣跨敤spring+hibernate榪欑鏋舵瀯灝辨樉寰楁瘮杈冮夯鐑︼紙鍘熷洜鏄痵pring MVC榪斿洖鐨勬槸涓涓?nbsp;PaginationSupport鐨勫璞★紝浣跨敤jstl浣滀負(fù)鍓嶇鏄劇ず鐨勮瘽錛屼細(xì)鍦╦sp欏甸潰涓幒鏉傚ぇ閲忕殑璁$畻錛屽儚涓嬩竴欏電儲寮曪紝鍏卞灝戞潯璁板綍錛屽綋鍓嶇鍑犻〉錛屽叡澶氬皯欏電瓑絳変細(xì)浣縥sp寰堥毦緇存姢錛変笅闈㈡槸瀵硅繖涓被鐨勬敼榪涳細(xì)<br /> </p> <p>public class  PaginationSupport {<br />  public final static int PAGESIZE = 30;</p> <p> private int pageSize = PAGESIZE;<br />  <br />  private int totalCount;</p> <p> private int currentPage;</p> <p> private int startIndex;<br />  <br />  private int[] indexes = new int[0];<br />  <br />  private int nextIndex;</p> <p> private int previousIndex;</p> <p> private int pageCount;</p> <p> private List items;<br />  <br />  private int lastIndex;<br />  <br />  public  PaginationSupport(int pageSize,<br />    int startIndex) {<br />   setPageSize(pageSize);<br />   setStartIndex(startIndex);<br />   <br />  }</p> <p> public  PaginationSupport(List items, int totalCount) {<br />   setPageSize(PAGESIZE);<br />   setTotalCount(totalCount);<br />   setItems(items);<br />   setStartIndex(0);<br />  <br />  }</p> <p> public  PaginationSupport(List items, int totalCount, int startIndex) {<br />   setPageSize(PAGESIZE);<br />   setTotalCount(totalCount);<br />   setItems(items);<br />   setStartIndex(startIndex);<br />   <br />  }</p> <p> public  PaginationSupport(List items, int totalCount, int pageSize,<br />    int startIndex) {<br />   setPageSize(pageSize);<br />   setTotalCount(totalCount);<br />   setItems(items);<br />   setStartIndex(startIndex);<br />   <br />  }</p> <p> <br />  public void setTotalCount(int totalCount) {<br />   if (totalCount > 0) {<br />    this.totalCount = totalCount;<br />    int count = totalCount / pageSize;<br />    if (totalCount % pageSize > 0)<br />     count++;<br />    indexes = new int[count];<br />    for (int i = 0; i < count; i++) {<br />     indexes[i] = pageSize * i;<br />    }<br />     } else {<br />    this.totalCount = 0;<br />   }<br />  }<br />  public int getTotalCount() {<br />   return totalCount;<br />  }<br />  public void setIndexes(int[] indexes) {<br />   this.indexes = indexes;<br />  }<br />  public int[] getIndexes() {<br />   return indexes;<br />  }</p> <p> <br />  public void setStartIndex(int startIndex) {<br />   if (totalCount <= 0)<br />    this.startIndex = 0;<br />   else if (startIndex >= totalCount)<br />    this.startIndex = indexes[indexes.length - 1];<br />   else if (startIndex < 0)<br />    this.startIndex = 0;<br />   else {<br />    this.startIndex = indexes[startIndex / pageSize];<br />   }<br />    }<br />  public int getStartIndex() {<br />   return startIndex;<br />  }</p> <p> <br />  public void setNextIndex(int nextIndex) {<br />   this.nextIndex = nextIndex;<br />  }<br />  public int getNextIndex() {<br />   int nextIndex = getStartIndex() + pageSize;<br />   if (nextIndex >= totalCount)<br />    return getStartIndex();<br />   else<br />    return nextIndex;<br />  }<br />  public void setPreviousIndex(int previousIndex) {<br />   this.previousIndex = previousIndex;<br />  }<br />  <br />  public int getPreviousIndex() {<br />   int previousIndex = getStartIndex() - pageSize;<br />   if (previousIndex < 0)<br />    return 0;<br />   else<br />    return previousIndex;<br />  }<br />  public void setPageCount(int pageCount) {<br />   this.pageCount = pageCount;<br />  }<br />  public int getPageCount() {<br />   int count = totalCount / pageSize;<br />   if (totalCount % pageSize > 0)<br />    count++;<br />   return count;<br />  }<br />  </p> <p> public int getCurrentPage() {<br />   return getStartIndex() / pageSize + 1;<br />  }</p> <p> public void setCurrentPage(int currentPage) {<br />   this.currentPage = currentPage;<br />  }<br /> <br />  public void setLastIndex(int lastIndex) {<br />   this.lastIndex =lastIndex ;<br />  }<br />  public int getLastIndex() {<br />   return indexes[indexes.length-1];<br />  }</p> <p> <br />  public int getPageSize() {<br />   return pageSize;<br />  }</p> <p> public void setPageSize(int pageSize) {<br />   this.pageSize = pageSize;<br />  }</p> <p> </p> <p> public List getItems() {<br />   return items;<br />  }</p> <p> public void setItems(List items) {<br />   this.items = items;<br />  }</p> <p><br /> }<br /> 浠ヤ笂鏄垎欏電殑灝佽綾伙紝涓嬮潰鏄敮鎸佸垎欏墊煡璇㈢殑鏂規(guī)硶錛?br /> 1錛?br /> public PaginationSupport findPageByCriteria(<br />    final DetachedCriteria detachedCriteria, final int pageSize,<br />    final int startIndex) {<br />   return (PaginationSupport) getHibernateTemplate().execute(<br />     new HibernateCallback() {<br />      public Object doInHibernate(Session session)<br />        throws HibernateException {<br />       Criteria criteria = detachedCriteria<br />         .getExecutableCriteria(session);<br />       int totalCount = ((Integer) criteria.setProjection(<br />         Projections.rowCount()).uniqueResult())<br />         .intValue();<br />       criteria.setProjection(null);<br />       List items = criteria.setFirstResult(startIndex)<br />         .setMaxResults(pageSize).list();<br />       PaginationSupport ps = new PaginationSupport(items,<br />         totalCount, pageSize, startIndex);<br />       return ps;<br />      }<br />     }, true);<br />  }<br /> 2錛?br /> public  PaginationSupport findPageByQuery( final  String hsql,  final int pageSize,final int startIndex){ <br />      return (PaginationSupport)getHibernateTemplate().execute( <br />      new  HibernateCallback() { <br />        public  Object doInHibernate(Session session)  throws  HibernateException, SQLException { <br />              Query query  =  session.createQuery(hsql);<br />              int totalCount=query.list().size();<br />              query.setFirstResult(startIndex); <br />              query.setMaxResults(pageSize); <br />              List items  = query.list();<br />           PaginationSupport ps = new PaginationSupport(items,<br />        totalCount, pageSize, startIndex);<br />           return ps;<br />              <br />              } <br />        },true); <br />   }<br /> 浣犱篃璁鎬細(xì)闂垎欏墊煡璇負(fù)浠涔堜細(xì)鎻愪緵涓や釜鏂規(guī)硶錛岃繖涓や釜鏂規(guī)硶鏈夊尯鍒悧錛熷叾瀹炶繖涓や釜鏂規(guī)硶騫舵棤鏈川鍖哄埆錛孌etachedCriteria 涔熸槸鏋勯犳煡璇㈣鍙ョ殑涓嶲uery鍔熻兘涓鑷達(dá)紝浣嗘槸瀹冩彁渚涗簡鏇村姞闈㈠悜瀵硅薄鐨勬柟娉曟潵鍐檋sql璇彞銆備竴鑸漢浠兘鍊懼悜絎竴縐嶆柟娉曪紝浣嗘槸榪欑鏂規(guī)硶騫朵笉閫氱敤錛屽畠鏈変竴縐嶆煡璇㈠茍涓嶆敮鎸侊紝閭e氨鏄綋浣犺鏌ヨ鐨勫璞″茍涓嶆槸涓涓崟涓瀵硅薄鐨勮瘽錛堜緥濡?浣犲湪鏁版嵁搴撲腑鏈変袱涓〃錛屼竴涓槸user,鍙︿竴涓槸userinfo,榪欎袱涓〃鎵瀵瑰簲鐨勫璞″湪hiberante涓鎸囧畾涓哄叡浜富閿殑璇濓紝鍦ㄦ墽琛屾煡璇㈢殑鏃跺欏氨浼?xì)鎶ゾc誨瀷杞崲寮傚父錛屽師鍥犳槸鏌ヨ鍑烘潵鐨勫璞″茍涓嶆槸user鑰屾槸涓涓寘鍚玼ser 鍜寀serinfo鐨凮bject,浣犺嫢寮哄埗鎶婂畠杞崲鎴恥ser綾誨瀷錛岃偗瀹氫細(xì)鍑洪敊),榪欐椂浣犱笉寰椾笉閲囩敤絎簩涓柟娉曘傚綋鐒惰繖鍙槸鎴戜釜浜鴻瑙o紝涔熻榪樻湁鍦版柟璇寸殑涓嶆槸寰堝噯紜紝甯屾湜澶у澶氬鎵硅瘎鎸囨銆?br /> 鏈鍚庢槸榪欎釜鍒嗛〉綾葷殑鍓嶅彴鏄劇ず婧愪唬鐮?<br /> <%@ page language="java" contentType="text/html; charset=gbk"<br />     pageEncoding="GBK"%><br /> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%><br /> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%><br /> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><br /> <html><br />   <head><br />   <link type="text/css" rel="stylesheet" href="../css/panel.css"><br />     <title>鏄劇ず鎵鏈夌敤鎴?lt;/title><br />   </head><br />   <br />   <body><br />     <div style="margin:20px auto 30px; width:70%;"><a href="index.jsp" class="btn2">榪斿洖棣栭〉</a></div><br />     <div style="margin:10px auto 0; width:70%;"><br />     <table width="100%" border="0" cellpadding="0" cellspacing="0"><br />     <caption><br />       鏄劇ず鎵鏈夌敤鎴?br />     </caption><br />     <tr><br />       <td>鐢ㄦ埛ID</td><br />       <td>鐢ㄦ埛鍚?lt;/td><br />    <td>鐢ㄦ埛鏄電О</td><br />       <td>鐢?shù)瀛愰偖錃g</td><br />       <td>娉ㄥ唽鏃墮棿</td><br />       <td>璇︾粏淇℃伅</td><br />       <td>鐢ㄦ埛鍏呭艱褰?lt;/td><br />       <td>鐢ㄦ埛瀹氬埗鏈嶅姟淇℃伅</td><br />     </tr><br /> <c:forEach var="user" items="${userPage.items}"><br />  <tr><br />    <td>${user.intId}</td><br />       <td>${user.username}</td><br />       <td>${user.name}</td><br />       <td>${user.email}</td><br />       <td><fmt:formatDate value='${user.creationTime}' pattern='yyyy-MM-dd HH:mm' /></td><br />    <td><a href="user_getdetailUser.ado?userId=${user.intId}" class="btn">璇︾粏淇℃伅</a></td><br />    <td><a href="orderService_getUserAccountAdds.ado?userId=${user.intId}" class="btn">鐢ㄦ埛鍏呭艱褰?lt;/a></td><br />    <td><a href="orderService_getUserChargeItems.ado?userId=${user.intId}" class="btn">鐢ㄦ埛瀹氬埗鏈嶅姟淇℃伅</a></td><br />  </tr><br /> </c:forEach><br />   </table><br />    <c:if test="${!empty userPage}"><br />      鍏?{userPage.totalCount}璁板綍 <br />      <c:choose><br />       <c:when test="${userPage.startIndex ne '0'}"><br />        <a href="user_getPage.ado?startIndex=0">棣栭〉</a><br />       </c:when><br />       <c:otherwise><br />        棣栭〉<br />       </c:otherwise><br />      </c:choose><br />      <c:choose><br />       <c:when test="${userPage.previousIndex lt userPage.startIndex}"><br />        <a href="user_getPage.ado?startIndex=${userPage.previousIndex }">涓婁竴欏?lt;/a><br />       </c:when><br />       <c:otherwise><br />        涓婁竴欏?br />       </c:otherwise><br />      </c:choose><br />      <c:choose><br />       <c:when test="${userPage.nextIndex>userPage.startIndex}"><br />        <a href="user_getPage.ado?startIndex=${userPage.nextIndex}">涓嬩竴欏?lt;/a><br />       </c:when><br />       <c:otherwise><br />        涓嬩竴欏?br />       </c:otherwise><br />      </c:choose><br />      <c:choose><br />       <c:when test="${userPage.lastIndex eq userPage.startIndex}"><br />        鏈鍚庝竴欏?br />       </c:when><br />       <c:otherwise><br />        <a href="user_getPage.ado?startIndex=${userPage.lastIndex}">鏈鍚庝竴欏?lt;/a><br />       </c:otherwise><br />      </c:choose><br />      姣忛〉鏄劇ず${userPage.pageSize}鏉¤褰?<br />      褰撳墠絎?{userPage.currentPage }/${userPage.pageCount}欏?br />   </c:if><br />     </div><br />   </body><br /> </html><br /> <br /> <br /> </p> </span> <img src ="http://m.tkk7.com/flustar/aggbug/160142.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/flustar/" target="_blank">flustar</a> 2007-11-13 10:50 <a href="http://m.tkk7.com/flustar/archive/2007/11/13/160142.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>感谢您访问我们的网站,您可能还对以下资源感兴趣:</p> <a href="http://m.tkk7.com/" title="亚洲av成人片在线观看">亚洲av成人片在线观看</a> <div class="friend-links"> </div> </div> </footer> 主站蜘蛛池模板: <a href="http://zuche001.com" target="_blank">亚洲a无码综合a国产av中文</a>| <a href="http://cc88899.com" target="_blank">宅男666在线永久免费观看</a>| <a href="http://992fanli.com" target="_blank">亚洲一区中文字幕久久</a>| <a href="http://777vip8.com" target="_blank">国产好大好硬好爽免费不卡</a>| <a href="http://5kee.com" target="_blank">亚洲国产精品嫩草影院在线观看</a>| <a href="http://aicbbs.com" target="_blank">波霸在线精品视频免费观看</a>| <a href="http://701807.com" target="_blank">久久影视综合亚洲</a>| <a href="http://69xjj.com" target="_blank">伊人免费在线观看</a>| <a href="http://whlnrsqsie.com" target="_blank">亚洲av无码片在线播放</a>| <a href="http://5138k.com" target="_blank">亚欧日韩毛片在线看免费网站</a>| <a href="http://tha2008.com" target="_blank">亚洲免费视频在线观看</a>| <a href="http://www97544.com" target="_blank">久久国产色AV免费观看</a>| <a href="http://jggbk.com" target="_blank">亚洲欧洲综合在线</a>| <a href="http://bjbanjia01.com" target="_blank">美女视频黄的全免费视频网站</a>| <a href="http://fdsyjy.com" target="_blank">亚洲免费观看在线视频</a>| <a href="http://szicon.com" target="_blank">毛片A级毛片免费播放</a>| <a href="http://haigoumama.com" target="_blank">亚洲gay片在线gv网站</a>| <a href="http://gg596gg.com" target="_blank">免费大香伊蕉在人线国产</a>| <a href="http://lookvod.com" target="_blank">国产99久久亚洲综合精品</a>| <a href="http://726zh.com" target="_blank">亚洲精品在线视频</a>| <a href="http://newbuybay.com" target="_blank">久久久久久毛片免费看</a>| <a href="http://2c06xyz.com" target="_blank">亚洲精品亚洲人成在线观看</a>| <a href="http://740740740.com" target="_blank">久艹视频在线免费观看</a>| <a href="http://cqkalai.com" target="_blank">亚洲欧洲国产经精品香蕉网</a>| <a href="http://av520av.com" target="_blank">免费精品人在线二线三线区别</a>| <a href="http://7272004.com" target="_blank">亚洲国产精品无码中文lv</a>| <a href="http://qingdaostf.com" target="_blank">免费真实播放国产乱子伦</a>| <a href="http://173ba.com" target="_blank">久久国产一片免费观看</a>| <a href="http://kouchoubao.com" target="_blank">久久亚洲国产视频</a>| <a href="http://caita88.com" target="_blank">国产免费的野战视频</a>| <a href="http://www-01313.com" target="_blank">亚洲AV无码精品国产成人</a>| <a href="http://www-533999.com" target="_blank">亚洲av无码天堂一区二区三区</a>| <a href="http://9v9av.com" target="_blank">美女无遮挡拍拍拍免费视频</a>| <a href="http://dsdkg.com" target="_blank">亚洲av福利无码无一区二区</a>| <a href="http://88533066.com" target="_blank">aⅴ免费在线观看</a>| <a href="http://lhtjdj.com" target="_blank">亚洲国产精品无码久久九九大片</a>| <a href="http://3t77.com" target="_blank">亚洲成片观看四虎永久</a>| <a href="http://wwwks2424.com" target="_blank">99久久国产精品免费一区二区</a>| <a href="http://usagaa.com" target="_blank">久久丫精品国产亚洲av</a>| <a href="http://aizaicc.com" target="_blank">在线观看人成网站深夜免费</a>| <a href="http://xx16xx.com" target="_blank">人成电影网在线观看免费</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>