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中封装表单的数据用到的是模型驱动,将数据封装为对象之后作为参数传递给相应地函数。

  • 相关阅读:
    [转载]Matlab实用小技巧
    Matlab rand randn randint
    Matlab取整
    Mathtype报错:MathType has detected an error in....
    [转载]十大编程算法助程序员走上高手之路
    (转)Free函数的参数一定要是malloc返回的那个指针
    sizeof,一个其貌不扬的家伙(转)
    ISO C Random Number Functions
    srand() rand() time(0)
    IOS之文件夹创建、删除,图片在本地的保存和加载
  • 原文地址:https://www.cnblogs.com/zhai1997/p/12487367.html
Copyright © 2011-2022 走看看