zoukankan      html  css  js  c++  java
  • struts_crm练习(条件查询、添加)

    1、导包

    (1)导入hibernate相关的包:

     (2)导入struts2相关的包:

     2、条件查询

    (1)条件查询的流程图:

     list.jsp可以向Action传递参数(即查询的条件),这里用的是离线查询DetachedCriteria,使用离线查询不用在dao层封装查询的参数,这里直接在web层封装查询的参数,最终,将得到的对象传递到dao层与session关联。

    (2)遍历接受的数据:

    方式一:

    先引入:

    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <c:forEach items="${list}" var="customer">
            <TR
           style="FONT-WEIGHT: normal; FONT-STYLE: normal; BACKGROUND-COLOR: white; TEXT-DECORATION: none">
               <TD>${customer.cust_name }</TD>
               <TD>${customer.cust_level }</TD>
               <TD>${customer.cust_source }</TD>
               <TD>${customer.cust_linkman }</TD>
               <TD>${customer.cust_phone }</TD>
               <TD>${customer.cust_mobile }</TD>
               <TD>
               <a href="${pageContext.request.contextPath }/customerServlet?method=edit&custId=${customer.cust_id}">修改</a>
                &nbsp;&nbsp;
                <a href="${pageContext.request.contextPath }/customerServlet?method=delete&custId=${customer.cust_id}">删除</a>
               </TD>
               </TR>
    
             </c:forEach>

    方式二:

    先引入:

    <%@ taglib uri="/struts-tags" prefix="s" %>
    <s:iterator value="#list" var="cust" >
    <TR         
        style="FONT-WEIGHT: normal; FONT-STYLE: normal; BACKGROUND-COLOR: white; TEXT-DECORATION: none">
        <TD>
        <s:property value="#cust.cust_name" />
        </TD>
        <TD>
        <s:property value="#cust.cust_level" />
        </TD>
        <TD>
        <s:property value="#cust.cust_source" />
         </TD>
         <TD>
         <s:property value="#cust.cust_linkman" />
          </TD>
         <TD>
          <s:property value="#cust.cust_phone" />
          </TD>
          <TD>
          <s:property value="#cust.cust_mobile" />
          </TD>
          <TD>
           <a href="${pageContext.request.contextPath }/customerServlet?method=edit&custId=${customer.cust_id}">修改</a>
           &nbsp;&nbsp;
           <a href="${pageContext.request.contextPath }/customerServlet?method=delete&custId=${customer.cust_id}">删除</a>
            </TD>
            </TR>
    </s:iterator>

    3、添加

     

     在action中封装表单的数据用到的是模型驱动,将数据封装为对象之后作为参数传递给相应地函数。

  • 相关阅读:
    基于bootsplash的嵌入式linux启动画面定制
    Android程式编写及调试新手入门3
    linux2.6 内核的 initrd
    exec与xargs区别 Leone
    jquery扩展方法:jquery.fn.extend与jquery.extend Leone
    MySQL查询in操作 查询结果按in集合顺序显示 Leone
    CentOS Linux Vsftp服务器配置 Leone
    linux[批量复制并重命名]和[批量复制文件到多个文件夹] Leone
    学会了这些保你5年内买车买房 Leone
    国外网赚项目的分类 Leone
  • 原文地址:https://www.cnblogs.com/zhai1997/p/12487367.html
Copyright © 2011-2022 走看看