1 案例分析

2 书写步骤

1.封装PageBean

2.书写Action

3.书写Service

4.书写Dao   注意清空之前设置的聚合函数  dc.setProjection(null);

5.完成strutx以及spring的配置

6.书写前台list.jsp页面

3 代码实现

1 封装PageBean

  1. package www.test.utils;
  2.  
  3. import java.util.List;
  4.  
  5. public class PageBean {
  6.  
  7. //当前页
  8. private Integer currentPage;
  9. //当前页显示的条数
  10. private Integer pageSize;
  11. //总页数
  12. private Integer totalPage;
  13. //总记录数
  14. private Integer totalCount;
  15.  
  16. //分页列表的数据
  17. private List list;
  18.  
  19. public PageBean(Integer currentPage, Integer pageSize, Integer totalCount) {
  20. this.currentPage = currentPage;
  21. this.pageSize = pageSize;
  22. this.totalCount = totalCount;
  23.  
  24. //如果没有指定显示那一页,就显示第一页。
  25. if (this.currentPage == null) {
  26. this.currentPage = 1;
  27. }
  28.  
  29. //如果没有指定每页显示几条数据,就默认显示3条。
  30. if (this.pageSize == null) {
  31. this.pageSize = 3;
  32. }
  33.  
  34. //计算总页数
  35. this.totalPage = (this.totalCount + this.pageSize - 1) / this.pageSize;
  36. //this.totalPage = (int) Math.ceil((this.totalCount*1.0)/this.pageSize);
  37.  
  38. //判断当前页数是否超出范围
  39. //不能小于1
  40. if (this.currentPage < 1) {
  41. this.currentPage = 1;
  42. }
  43. //不能大于总页数
  44. if (this.currentPage > this.totalPage) {
  45. this.currentPage = this.totalPage;
  46. }
  47. }
  48.  
  49. //计算起始索引
  50. public Integer getStart() {
  51. return (this.currentPage - 1) * this.pageSize;
  52. }
  53.  
  54. public Integer getCurrentPage() {
  55. return currentPage;
  56. }
  57.  
  58. public void setCurrentPage(Integer currentPage) {
  59. this.currentPage = currentPage;
  60. }
  61.  
  62. public Integer getPageSize() {
  63. return pageSize;
  64. }
  65.  
  66. public void setPageSize(Integer pageSize) {
  67. this.pageSize = pageSize;
  68. }
  69.  
  70. public Integer getTotalPage() {
  71. return totalPage;
  72. }
  73.  
  74. public void setTotalPage(Integer totalPage) {
  75. this.totalPage = totalPage;
  76. }
  77.  
  78. public Integer getTotalCount() {
  79. return totalCount;
  80. }
  81.  
  82. public void setTotalCount(Integer totalCount) {
  83. this.totalCount = totalCount;
  84. }
  85.  
  86. public List getList() {
  87. return list;
  88. }
  89.  
  90. public void setList(List list) {
  91. this.list = list;
  92. }
  93.  
  94. }

2.书写Action

  1. package www.test.web.action;
  2.  
  3. import org.apache.commons.lang3.StringUtils;
  4. import org.hibernate.criterion.DetachedCriteria;
  5. import org.hibernate.criterion.Restrictions;
  6.  
  7. import com.opensymphony.xwork2.ActionContext;
  8. import com.opensymphony.xwork2.ActionSupport;
  9. import com.opensymphony.xwork2.ModelDriven;
  10.  
  11. import www.test.domain.Customer;
  12. import www.test.service.CustomerService;
  13. import www.test.utils.PageBean;
  14.  
  15. public class CustomerAction extends ActionSupport implements ModelDriven<Customer>{
  16.  
  17. private Customer customer = new Customer();
  18.  
  19. private CustomerService cs;
  20. private Integer currentPage;
  21. private Integer pageSize;
  22.  
  23. //获取客户列表
  24. public String list() throws Exception {
  25. //封装离线查询对象
  26. DetachedCriteria dc = DetachedCriteria.forClass(Customer.class);
  27.  
  28. //判断并封装参数
  29. if(StringUtils.isNotBlank(customer.getCust_name())){
  30. dc.add(Restrictions.like("cust_name", "%"+customer.getCust_name()+"%"));
  31. }
  32.  
  33. //1 调用Service查询分页数据(PageBean)
  34. PageBean pb = cs.getPageBean(dc,currentPage,pageSize);
  35. //2 将PageBean放入request域,转发到列表页面显示
  36. ActionContext.getContext().put("pageBean", pb);
  37. return "list";
  38. }
  39.  
  40. @Override
  41. public Customer getModel() {
  42.  
  43. return customer;
  44. }
  45.  
  46. public CustomerService getCs() {
  47. return cs;
  48. }
  49.  
  50. public void setCs(CustomerService cs) {
  51. this.cs = cs;
  52. }
  53.  
  54. public Integer getCurrentPage() {
  55. return currentPage;
  56. }
  57.  
  58. public void setCurrentPage(Integer currentPage) {
  59. this.currentPage = currentPage;
  60. }
  61.  
  62. public Integer getPageSize() {
  63. return pageSize;
  64. }
  65.  
  66. public void setPageSize(Integer pageSize) {
  67. this.pageSize = pageSize;
  68. }
  69.  
  70. }

3.书写Service

  1. package www.test.service;
  2.  
  3. import org.hibernate.criterion.DetachedCriteria;
  4.  
  5. import www.test.utils.PageBean;
  6.  
  7. public interface CustomerService {
  8.  
  9. PageBean getPageBean(DetachedCriteria dc, Integer currentPage, Integer pageSize);
  10.  
  11. }
  1. package www.test.service.impl;
  2.  
  3. import java.util.List;
  4.  
  5. import org.hibernate.criterion.DetachedCriteria;
  6.  
  7. import www.test.dao.CustomerDao;
  8. import www.test.domain.Customer;
  9. import www.test.service.CustomerService;
  10. import www.test.utils.PageBean;
  11.  
  12. public class CustomerServiceImpl implements CustomerService {
  13.  
  14. private CustomerDao cd;
  15. @Override
  16. public PageBean getPageBean(DetachedCriteria dc, Integer currentPage, Integer pageSize) {
  17.  
  18. // 1 调用dao层查询总记录数
  19. Integer totalCount = cd.getTotalCount(dc);
  20.  
  21. // 2创建pageBean对象
  22. PageBean pb = new PageBean(currentPage, pageSize, totalCount);
  23.  
  24. // 3查询客户列表
  25. List<Customer> list = cd.getPageList(dc,pb.getStart(),pb.getPageSize());
  26.  
  27. // 4返回pageBean
  28. pb.setList(list);
  29. return pb;
  30. }
  31. public CustomerDao getCd() {
  32. return cd;
  33. }
  34. public void setCd(CustomerDao cd) {
  35. this.cd = cd;
  36. }
  37.  
  38. }

4.书写Dao

  1. package www.test.dao;
  2.  
  3. import java.util.List;
  4.  
  5. import org.hibernate.criterion.DetachedCriteria;
  6.  
  7. import www.test.domain.Customer;
  8.  
  9. public interface CustomerDao {
  10.  
  11. //查询总记录数
  12. Integer getTotalCount(DetachedCriteria dc);
  13.  
  14. //根据条件查询客户列表
  15. List<Customer> getPageList(DetachedCriteria dc, Integer start, Integer pageSize);
  16.  
  17. }
  1. package www.test.dao.impl;
  2.  
  3. import java.util.List;
  4.  
  5. import org.hibernate.criterion.DetachedCriteria;
  6. import org.hibernate.criterion.Projection;
  7. import org.hibernate.criterion.Projections;
  8. import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
  9.  
  10. import www.test.dao.CustomerDao;
  11. import www.test.domain.Customer;
  12.  
  13. public class CustomerDaoImpl extends HibernateDaoSupport implements CustomerDao{
  14.  
  15. @Override
  16. public Integer getTotalCount(DetachedCriteria dc) {
  17. //设置查询聚合函数,总记录数
  18. dc.setProjection(Projections.rowCount());
  19.  
  20. List<Long> list = (List<Long>) super.getHibernateTemplate().findByCriteria(dc);
  21.  
  22. //清空之前设置的聚合函数
  23. dc.setProjection(null);
  24. if(list!=null&&list.size()>0){
  25. Long count = list.get(0);
  26. return count.intValue();
  27. }else{
  28. return null;
  29. }
  30. }
  31.  
  32. @Override
  33. public List<Customer> getPageList(DetachedCriteria dc, Integer start, Integer pageSize) {
  34.  
  35. List<Customer> list = (List<Customer>) super.getHibernateTemplate().findByCriteria(dc, start, pageSize);
  36. return list;
  37. }
  38.  
  39. }

5.完成strutx以及spring的配置

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE struts PUBLIC
  3. "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
  4. "http://struts.apache.org/dtds/struts-2.3.dtd">
  5. <struts>
  6. <!-- <constant name="struts.devMode" value="true"></constant> -->
  7.  
  8. <!--
  9. #struts.objectFactory = spring 将action的创建交给spring容器
  10. struts.objectFactory.spring.autoWire = name spring负责装配Action依赖属性
  11. -->
  12. <constant name="struts.objectFactory" value="spring"></constant>
  13.  
  14. <package name="crm" namespace="/" extends="struts-default">
  15.  
  16. <global-exception-mappings>
  17. <exception-mapping result="error" exception="java.lang.RuntimeException"></exception-mapping>
  18. </global-exception-mappings>
  19. <action name="UserAction_*" class="userAction" method="{1}">
  20. <result name="toHome" type="redirect">/index.htm</result>
  21. <result name="error" type="dispatcher">/login.jsp</result>
  22. </action>
  23. <action name="CustomerAction_*" class="customerAction" method="{1}">
  24. <result name="list" type="dispatcher">/jsp/customer/list.jsp</result>
  25. </action>
  26. </package>
  27. </struts>
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xmlns="http://www.springframework.org/schema/beans"
  4. xmlns:context="http://www.springframework.org/schema/context"
  5. xmlns:aop="http://www.springframework.org/schema/aop"
  6. xmlns:tx="http://www.springframework.org/schema/tx"
  7. xsi:schemaLocation="http://www.springframework.org/schema/beans
  8. http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
  9. http://www.springframework.org/schema/context
  10. http://www.springframework.org/schema/context/spring-context-4.2.xsd
  11. http://www.springframework.org/schema/aop
  12. http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
  13. http://www.springframework.org/schema/tx
  14. http://www.springframework.org/schema/tx/spring-tx-4.2.xsd ">
  15.  
  16. <!--5 读取database.properties文件 -->
  17. <context:property-placeholder location="classpath:database.properties"/>
  18.  
  19. <!--6 准备druid连接池 -->
  20. <bean name="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
  21. <property name="driverClassName" value="${jdbc.driverClass}"></property>
  22. <property name="url" value="${jdbc.jdbcUrl}"></property>
  23. <property name="username" value="${jdbc.user}"></property>
  24. <property name="password" value="${jdbc.password}"></property>
  25. </bean>
  26.  
  27. <!--7 核心事务管理器 依赖于SessionFactory-->
  28. <bean name="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
  29. <property name="sessionFactory" ref="sessionFactory"></property>
  30. </bean>
  31.  
  32. <!--8 配置通知 -->
  33. <tx:advice id="txAdvice" transaction-manager="transactionManager">
  34. <tx:attributes>
  35. <tx:method name="save*" isolation="REPEATABLE_READ" propagation="REQUIRED" read-only="false"/>
  36. <tx:method name="persist*" isolation="REPEATABLE_READ" propagation="REQUIRED" read-only="false"/>
  37. <tx:method name="update*" isolation="REPEATABLE_READ" propagation="REQUIRED" read-only="false"/>
  38. <tx:method name="modify*" isolation="REPEATABLE_READ" propagation="REQUIRED" read-only="false"/>
  39. <tx:method name="delete*" isolation="REPEATABLE_READ" propagation="REQUIRED" read-only="false"/>
  40. <tx:method name="remove*" isolation="REPEATABLE_READ" propagation="REQUIRED" read-only="false"/>
  41. <tx:method name="find*" isolation="REPEATABLE_READ" propagation="REQUIRED" read-only="true"/>
  42. <tx:method name="get*" isolation="REPEATABLE_READ" propagation="REQUIRED" read-only="true"/>
  43. </tx:attributes>
  44. </tx:advice>
  45.  
  46. <!--9 配置将通知织入目标对象 配置切点+配置切面 -->
  47. <aop:config>
  48. <aop:pointcut expression="execution(* www.test.service.impl.*ServiceImpl.*(..))" id="txPc"/>
  49. <aop:advisor advice-ref="txAdvice" pointcut-ref="txPc"/>
  50. </aop:config>
  51.  
  52. <!--1 action -->
  53. <bean name="userAction" class="www.test.web.action.UserAction" scope="prototype">
  54. <property name="us" ref="userService"></property>
  55. </bean>
  56. <bean name="customerAction" class="www.test.web.action.CustomerAction" scope="prototype">
  57. <property name="cs" ref="customerService"></property>
  58. </bean>
  59.  
  60. <!--2 service -->
  61. <bean name="userService" class="www.test.service.impl.UserServiceImpl">
  62. <property name="ud" ref="userDao"></property>
  63. </bean>
  64. <bean name="customerService" class="www.test.service.impl.CustomerServiceImpl">
  65. <property name="cd" ref="customerDao"></property>
  66. </bean>
  67.  
  68. <!--3 dao -->
  69. <bean name="userDao" class="www.test.dao.impl.UserDaoImpl">
  70. <property name="sessionFactory" ref="sessionFactory"></property>
  71. </bean>
  72. <bean name="customerDao" class="www.test.dao.impl.CustomerDaoImpl">
  73. <property name="sessionFactory" ref="sessionFactory"></property>
  74. </bean>
  75.  
  76. <!--4 将SessionFactory配置到spring容器中 -->
  77. <!-- 加载配置方案1:仍然使用外部的hibernate.cfg.xml配置信息 -->
  78. <!-- <bean name="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
  79. <property name="configLocation" value="classpath:hibernate.cfg.xml"></property>
  80. </bean> -->
  81.  
  82. <!-- 加载配置方案2:在spring配置中放置hibernate配置信息 -->
  83. <bean name="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
  84. <!-- 将连接池注入到sessionFactory, hibernate会通过连接池获得连接 -->
  85. <property name="dataSource" ref="dataSource"></property>
  86. <!-- 配置hibernate基本信息 -->
  87. <property name="hibernateProperties">
  88. <props>
  89. <!-- 必选配置 -->
  90. <!-- <prop key="hibernate.connection.driver_class">com.mysql.jdbc.Driver</prop>
  91. <prop key="hibernate.connection.url">jdbc:mysql:///hibernate</prop>
  92. <prop key="hibernate.connection.username">root</prop>
  93. <prop key="hibernate.connection.password">root</prop> -->
  94. <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
  95.  
  96. <!-- 可选配置 -->
  97. <prop key="hibernate.show_sql">true</prop>
  98. <prop key="hibernate.format_sql">true</prop>
  99. <prop key="hibernate.hbm2ddl.auto">update</prop>
  100. </props>
  101. </property>
  102. <!-- 引入orm元数据,指定orm元数据所在的包路径,spring会自动读取包中的所有配置 -->
  103. <property name="mappingDirectoryLocations" value="classpath:www/test/domain"></property>
  104. </bean>
  105.  
  106. </beans>

6.书写前台list.jsp页面

  1. <%@ page language="java" contentType="text/html; charset=UTF-8"
  2. pageEncoding="UTF-8"%>
  3. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
  4. <%@ taglib prefix="s" uri="/struts-tags"%>
  5. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  6. <html>
  7. <head>
  8. <TITLE>客户列表</TITLE>
  9. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  10. <LINK href="${pageContext.request.contextPath }/css/Style.css"
  11. type=text/css rel=stylesheet>
  12. <LINK href="${pageContext.request.contextPath }/css/Manage.css"
  13. type=text/css rel=stylesheet>
  14. <script type="text/javascript"
  15. src="${pageContext.request.contextPath }/js/jquery-1.4.4.min.js"></script>
  16. <SCRIPT language=javascript>
  17. function changePage(pageNum){
  18. //alert(pageNum);
  19. //1 将页码的值放入对应表单隐藏域中
  20. $("#currentPageInput").val(pageNum);
  21. //2提交表达
  22. $("#pageForm").submit();
  23. }
  24.  
  25. function changePageSize(pageSize){
  26. //alert(pageSize);
  27. //1 将页码的值放入对应表单隐藏域中
  28. $("#pageSizeInput").val(pageSize);
  29. //2提交表达
  30. $("#pageForm").submit();
  31. }
  32. </SCRIPT>
  33.  
  34. <META content="MSHTML 6.00.2900.3492" name=GENERATOR>
  35. </HEAD>
  36. <BODY>
  37. <TABLE cellSpacing=0 cellPadding=0 width="98%" border=0>
  38. <TBODY>
  39. <TR>
  40. <TD width=15><IMG
  41. src="${pageContext.request.contextPath }/images/new_019.jpg"
  42. border=0></TD>
  43. <TD width="100%"
  44. background="${pageContext.request.contextPath }/images/new_020.jpg"
  45. height=20></TD>
  46. <TD width=15><IMG
  47. src="${pageContext.request.contextPath }/images/new_021.jpg"
  48. border=0></TD>
  49. </TR>
  50. </TBODY>
  51. </TABLE>
  52. <TABLE cellSpacing=0 cellPadding=0 width="98%" border=0>
  53. <TBODY>
  54. <TR>
  55. <TD width=15 background=${pageContext.request.contextPath }
  56. /images/new_022.jpg><IMG
  57. src="${pageContext.request.contextPath }/images/new_022.jpg"
  58. border=0></TD>
  59. <TD vAlign=top width="100%" bgColor=#ffffff>
  60. <TABLE cellSpacing=0 cellPadding=5 width="100%" border=0>
  61. <TR>
  62. <TD class=manageHead>当前位置:客户管理 &gt; 客户列表</TD>
  63. </TR>
  64. <TR>
  65. <TD height=2></TD>
  66. </TR>
  67. </TABLE>
  68. <TABLE borderColor=#cccccc cellSpacing=0 cellPadding=0 width="100%"
  69. align=center border=0>
  70. <TBODY>
  71. <TR>
  72. <TD height=25>
  73. <FORM id="pageForm" name="customerForm"
  74. action="${pageContext.request.contextPath }/CustomerAction_list"
  75. method=post>
  76. <!-- 隐藏域 用于传递当前页面 -->
  77. <input type="hidden" name="currentPage" id="currentPageInput"
  78. value="<s:property value="#pageBean.currentPage"/>">
  79. <!-- 隐藏域 用于传递每页显示的条数 -->
  80. <input type="hidden" name="pageSize" id="pageSizeInput"
  81. value="<s:property value="#pageBean.pageSize"/>">
  82.  
  83. <TABLE cellSpacing=0 cellPadding=2 border=0>
  84. <TBODY>
  85. <TR>
  86. <TD>客户名称:</TD>
  87. <TD><INPUT class=textbox id=sChannel2
  88. style="WIDTH: 80px" maxLength=50 name="cust_name"
  89. value="${param.cust_name}"></TD>
  90.  
  91. <TD><INPUT class=button id=sButton2 type=submit
  92. value=" 筛选 " name=sButton2></TD>
  93. </TR>
  94. </TBODY>
  95. </TABLE>
  96. </FORM>
  97. </TD>
  98. </TR>
  99.  
  100. <TR>
  101. <TD>
  102. <TABLE id=grid
  103. style="BORDER-TOP-WIDTH: 0px; FONT-WEIGHT: normal; BORDER-LEFT-WIDTH: 0px; BORDER-LEFT-COLOR: #cccccc; BORDER-BOTTOM-WIDTH: 0px; BORDER-BOTTOM-COLOR: #cccccc; WIDTH: 100%; BORDER-TOP-COLOR: #cccccc; FONT-STYLE: normal; BACKGROUND-COLOR: #cccccc; BORDER-RIGHT-WIDTH: 0px; TEXT-DECORATION: none; BORDER-RIGHT-COLOR: #cccccc"
  104. cellSpacing=1 cellPadding=2 rules=all border=0>
  105. <TBODY>
  106. <TR
  107. style="FONT-WEIGHT: bold; FONT-STYLE: normal; BACKGROUND-COLOR: #eeeeee; TEXT-DECORATION: none">
  108. <TD>客户名称</TD>
  109. <TD>客户级别</TD>
  110. <TD>客户来源</TD>
  111. <TD>联系人</TD>
  112. <TD>电话</TD>
  113. <TD>手机</TD>
  114. <TD>操作</TD>
  115. </TR>
  116. <s:iterator value="#pageBean.list" var="cust">
  117. <TR
  118. style="FONT-WEIGHT: normal; FONT-STYLE: normal; BACKGROUND-COLOR: white; TEXT-DECORATION: none">
  119. <TD><s:property value="#cust.cust_name" /></TD>
  120. <TD><s:property value="#cust.cust_level" /></TD>
  121. <TD><s:property value="#cust.cust_source" /></TD>
  122. <TD><s:property value="#cust.cust_linkman" /></TD>
  123. <TD><s:property value="#cust.cust_phone" /></TD>
  124. <TD><s:property value="#cust.cust_mobile" /></TD>
  125. <TD><a
  126. href="${pageContext.request.contextPath }/customerServlet?method=edit&custId=${customer.cust_id}">修改</a>
  127. &nbsp;&nbsp; <a
  128. href="${pageContext.request.contextPath }/customerServlet?method=delete&custId=${customer.cust_id}">删除</a>
  129. </TD>
  130. </TR>
  131. </s:iterator>
  132. <%-- <s:iterator value="#list" >
  133. <TR
  134. style="FONT-WEIGHT: normal; FONT-STYLE: normal; BACKGROUND-COLOR: white; TEXT-DECORATION: none">
  135. <TD>
  136. <s:property value="cust_name" />
  137. </TD>
  138. <TD>
  139. <s:property value="cust_level" />
  140. </TD>
  141. <TD>
  142. <s:property value="cust_source" />
  143. </TD>
  144. <TD>
  145. <s:property value="cust_linkman" />
  146. </TD>
  147. <TD>
  148. <s:property value="cust_phone" />
  149. </TD>
  150. <TD>
  151. <s:property value="cust_mobile" />
  152. </TD>
  153. <TD>
  154. <a href="${pageContext.request.contextPath }/customerServlet?method=edit&custId=${customer.cust_id}">修改</a>
  155. &nbsp;&nbsp;
  156. <a href="${pageContext.request.contextPath }/customerServlet?method=delete&custId=${customer.cust_id}">删除</a>
  157. </TD>
  158. </TR>
  159. </s:iterator> --%>
  160. <%-- <c:forEach items="${list }" var="customer">
  161. <TR
  162. style="FONT-WEIGHT: normal; FONT-STYLE: normal; BACKGROUND-COLOR: white; TEXT-DECORATION: none">
  163. <TD>${customer.cust_name }</TD>
  164. <TD>${customer.cust_level }</TD>
  165. <TD>${customer.cust_source }</TD>
  166. <TD>${customer.cust_linkman }</TD>
  167. <TD>${customer.cust_phone }</TD>
  168. <TD>${customer.cust_mobile }</TD>
  169. <TD>
  170. <a href="${pageContext.request.contextPath }/customerServlet?method=edit&custId=${customer.cust_id}">修改</a>
  171. &nbsp;&nbsp;
  172. <a href="${pageContext.request.contextPath }/customerServlet?method=delete&custId=${customer.cust_id}">删除</a>
  173. </TD>
  174. </TR>
  175.  
  176. </c:forEach> --%>
  177.  
  178. </TBODY>
  179. </TABLE>
  180. </TD>
  181. </TR>
  182.  
  183. <TR>
  184. <TD><SPAN id=pagelink>
  185. <DIV
  186. style="LINE-HEIGHT: 20px; HEIGHT: 20px; TEXT-ALIGN: right">
  187. 共[<B><s:property value="#pageBean.totalCount" /></B>]条记 录,[<B>
  188. <s:property value="#pageBean.currentPage" />
  189. </B>]页 ,每页显示
  190. <select name="pageSize" id="selectPageSize" onchange="changePageSize($('#selectPageSize option:selected').val())" >
  191. <option value="1" <s:property value="#pageBean.pageSize==1?'selected':''"/>>1</option>
  192. <option value="2" <s:property value="#pageBean.pageSize==2?'selected':''"/>>2</option>
  193. <option value="3" <s:property value="#pageBean.pageSize==3?'selected':''"/>>3</option>
  194. <option value="4" <s:property value="#pageBean.pageSize==4?'selected':''"/>>4</option>
  195. <option value="5" <s:property value="#pageBean.pageSize==5?'selected':''"/>>5</option>
  196. </select>
  197. [<A href="javaScript:void(0)"
  198. onclick="changePage(<s:property value='#pageBean.currentPage-1' />)">前一页</A>]
  199. <%-- <B>${page}</B> --%>
  200. [<A href="javaScript:void(0)"
  201. onclick="changePage(<s:property value='#pageBean.currentPage+1' />)">后一页</A>]
  202. 到 <input type="text" size="3" id="page" name="page"
  203. value="<s:property value='#pageBean.currentPage'/>" /> 页 <input
  204. type="button" value="Go"
  205. onclick="changePage($('#page').val())" />
  206. </DIV>
  207. </SPAN></TD>
  208. </TR>
  209. </TBODY>
  210. </TABLE>
  211. </TD>
  212. <TD width=15
  213. background="${pageContext.request.contextPath }/images/new_023.jpg"><IMG
  214. src="${pageContext.request.contextPath }/images/new_023.jpg"
  215. border=0></TD>
  216. </TR>
  217. </TBODY>
  218. </TABLE>
  219. <TABLE cellSpacing=0 cellPadding=0 width="98%" border=0>
  220. <TBODY>
  221. <TR>
  222. <TD width=15><IMG
  223. src="${pageContext.request.contextPath }/images/new_024.jpg"
  224. border=0></TD>
  225. <TD align=middle width="100%"
  226. background="${pageContext.request.contextPath }/images/new_025.jpg"
  227. height=15></TD>
  228. <TD width=15><IMG
  229. src="${pageContext.request.contextPath }/images/new_026.jpg"
  230. border=0></TD>
  231. </TR>
  232. </TBODY>
  233. </TABLE>
  234. </BODY>
  235. </HTML>

案例49-crm练习获取客户列表带有分页和筛选功能的更多相关文章

  1. 案例42-使用ajax获取crm中的客户列表

    1webcontent部分 1 修改menu.jsp代码 2 jsp/customer/list.jsp代码 <%@ page language="java" content ...

  2. 案例43-crm练习获取客户列表使用struts2

    1 src下配置文件 1 struts.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYP ...

  3. crm --- 1.admin , 展示列表 和 分页

    一.admin (创建超级用户) 1.注册: 1.创建一个超级管理员,使用如下命令: python manage.py createsuperuser 2.输入打算使用的登录名: username:m ...

  4. 一步一步搭建客服系统 (4) 客户列表 - JS($.ajax)调用WCF 遇到的各种坑

    本文以一个生成.获取“客户列表”的demo来介绍如何用js调用wcf,以及遇到的各种问题. 1 创建WCF服务 1.1 定义接口 创建一个接口,指定用json的格式:   [ServiceContra ...

  5. 【JAVAEE学习笔记】hibernate04:查询种类、HQL、Criteria、查询优化和练习为客户列表增加查询条件

    一.查询种类 1.oid查询-get 2.对象属性导航查询 3.HQL 4.Criteria 5.原生SQL 二.查询-HQL语法 //学习HQL语法 public class Demo { //基本 ...

  6. JAVAEE学习——hibernate04:查询种类、HQL、Criteria、查询优化和练习为客户列表增加查询条件

    一.查询种类 1.oid查询-get 2.对象属性导航查询 3.HQL 4.Criteria 5.原生SQL 二.查询-HQL语法 //学习HQL语法 public class Demo { //基本 ...

  7. 案例52-crm练习新增客户中加入文件上传功能(struts2文件上传)

    1 jsp/customer/add.jsp 完整代码: <%@ page language="java" contentType="text/html; char ...

  8. SSM项目使用GoEasy 获取客户端上下线实时状态变化及在线客户列表

    一.背景 上篇SSM项目使用GoEasy 实现web消息推送服务是GoEasy的一个用途,今天我们来看GoEasy的第二个用途:订阅客户端上下线实时状态变化.获取当前在线客户数量和在线客户列表.截止我 ...

  9. Python-装饰器-案例-获取文件列表

    import os def get_all_path(fun): '''装饰器.功能:获取全路径文件名.如:D:/tmp/12.txt :param fun: :return:file_path_li ...

随机推荐

  1. C# 写 LeetCode easy #14 Longest Common Prefix

    14.Longest Common Prefix Write a function to find the longest common prefix string amongst an array ...

  2. c#操作json 使用JavaScriptSerializer

    需要引用:System.Web.Extensions /// <summary> /// json的信息.保证定义的变量和json的字段一样(也可以使用struct) /// </s ...

  3. centoOS下安装python3 和 pip: command not found

    在更新python3的时候会自动安装pip3,但是安装完成后,pip -V发现出错:command not found,找了好久,发现在建立软连接的时候路径写错了. 总结一下安装python3和发现p ...

  4. UGUI 深度優化提升手遊效能

    https://hackmd.io/s/S1z1ByaGb#UGUI-%E6%B7%B1%E5%BA%A6%E5%84%AA%E5%8C%96%E6%8F%90%E5%8D%87%E6%89%8B%E ...

  5. (Python OpenGL)【3】着色器 PyOpenGL

    (Python OpenGL)现在开始我们使用着色器来进行渲染.着色器是目前做3D图形最流行的方式. OpenGL的渲染管线流程: 数据传输到OpenGL—>顶点处理器—>细分着色—> ...

  6. 模板【洛谷P3390】 【模板】矩阵快速幂

    P3390 [模板]矩阵快速幂 题目描述 给定n*n的矩阵A,求A^k 矩阵A的大小为n×m,B的大小为n×k,设C=A×B 则\(C_{i,j}=\sum\limits_{k=1}^{n}A_{i, ...

  7. CF581D Three Logos 暴力

    Three companies decided to order a billboard with pictures of their logos. A billboard is a big squa ...

  8. 勤哲excel服务器WEB网页环境搭建问题解决

    因为客户希望在浏览器上使用勤哲的功能,因此希望大家勤哲excel服务器的web环境. 他们用的是勤哲2010版,需要装到64位环境下.在搭建的时候,遇到2个主要问题. 问题1:编译器错误消息: BC3 ...

  9. Eclipse导入GitHub项目两处报错处理

    1.项目出现Could not calculate build plan:pligin 错误解决办法: 删除本地.m2仓库中 org.apache.maven.plugins:maven-resour ...

  10. SprimgMVC学习笔记(七)—— 上传图片

    一.配置虚拟目录 在tomcat上配置图片虚拟目录,在tomcat下conf/server.xml中添加: <Context docBase="D:\upload\temp" ...