首页 > 其他 > 详细

struts_crm练习(条件查询、添加)

时间:2020-03-13 20:24:52      阅读:63      评论:0      收藏:0      [点我收藏+]

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

 

struts_crm练习(条件查询、添加)

原文:https://www.cnblogs.com/zhai1997/p/12487367.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!