码迷,mamicode.com
首页 > Web开发 > 详细

Web 条件查询、分页查

时间:2019-07-13 13:25:48      阅读:117      评论:0      收藏:0      [点我收藏+]

标签:mouse   input   cin   hot   public   div   order   weight   sheet   

在table表格上 创建几个按钮

  1 <%@ page language="java" pageEncoding="UTF-8"%>
  2 <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
  3 <HTML>
  4 <HEAD>
  5 <meta http-equiv="Content-Language" content="zh-cn">
  6 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  7 <link href="${pageContext.request.contextPath}/css/Style1.css"
  8     rel="stylesheet" type="text/css" />
  9 <script language="javascript"
 10     src="${pageContext.request.contextPath}/js/public.js"></script>
 11 <script type="text/javascript">
 12     function addProduct() {
 13         window.location.href = "${pageContext.request.contextPath}/AddProductUIServlet";
 14     }
 15     function del(pid){
 16         var isdel=confirm("确认删除吗?");
 17         if(isdel){
 18             location.href = "${pageContext.request.contextPath}/DeleteProductServlet?pid="+pid;
 19         }
 20     }
 21 </script>
 22 </HEAD>
 23 <body>
 24     <br>
 25     <form id="Form1" name="Form1"
 26         action="${pageContext.request.contextPath}/ConditionServlet"
 27         method="post">
 28         商品名称:<input type="text" name="pname">
 29         是否热门:<select name="is_hot">
 30                     <option value="">请选择</option>
 31                     <option value="1">是</option>
 32                     <option value="0">否</option>
 33                 </select>
 34         所属分类:<select name="cid">
 35                     <option value="">请选择</option>
 36                     <c:forEach items="${CategoryList }" var="cate">
 37                         <option value="${cate.cid }">${cate.cname }</option>
 38                     </c:forEach>
 39                 </select>
 40         <input type="submit" value="搜索">        
 41         <table cellSpacing="1" cellPadding="0" width="100%" align="center"
 42             bgColor="#f5fafe" border="0">
 43             <TBODY>
 44                 <tr>
 45                     <td class="ta_01" align="center" bgColor="#afd1f3"><strong>商品列表</strong>
 46                     </TD>
 47                 </tr>
 48                 <tr>
 49                     <td class="ta_01" align="right">
 50                         <button type="button" id="add" name="add" value="添加"
 51                             class="button_add" onclick="addProduct()">
 52                             &#28155;&#21152;</button>
 53 
 54                     </td>
 55                 </tr>
 56                 <tr>
 57                     <td class="ta_01" align="center" bgColor="#f5fafe">
 58                         <table cellspacing="0" cellpadding="1" rules="all"
 59                             bordercolor="gray" border="1" id="DataGrid1"
 60                             style="BORDER-RIGHT: gray 1px solid; BORDER-TOP: gray 1px solid; BORDER-LEFT: gray 1px solid; WIDTH: 100%; WORD-BREAK: break-all; BORDER-BOTTOM: gray 1px solid; BORDER-COLLAPSE: collapse; BACKGROUND-COLOR: #f5fafe; WORD-WRAP: break-word">
 61                             <tr
 62                                 style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; HEIGHT: 25px; BACKGROUND-COLOR: #afd1f3">
 63 
 64                                 <td align="center" width="18%">序号</td>
 65                                 <td align="center" width="17%">商品图片</td>
 66                                 <td align="center" width="17%">商品名称</td>
 67                                 <td align="center" width="17%">商品价格</td>
 68                                 <td align="center" width="17%">是否热门</td>
 69                                 <td width="7%" align="center">编辑</td>
 70                                 <td width="7%" align="center">删除</td>
 71                             </tr>
 72                             <c:forEach items="${ProductList }" var="pro" varStatus="vs">
 73                                 <tr onmouseover="this.style.backgroundColor = ‘white‘"
 74                                     onmouseout="this.style.backgroundColor = ‘#F5FAFE‘;">
 75                                     <td style="CURSOR: hand; HEIGHT: 22px" align="center"
 76                                         width="18%" >${vs.count }</td>
 77                                     <td style="CURSOR: hand; HEIGHT: 22px" align="center"
 78                                         width="17%"><img width="40" height="45"
 79                                         src="${pageContext.request.contextPath }/${pro.pimage}"></td>
 80                                     <td style="CURSOR: hand; HEIGHT: 22px" align="center"
 81                                         width="17%">${pro.pname }</td>
 82                                     <td style="CURSOR: hand; HEIGHT: 22px" align="center"
 83                                         width="17%">${pro.market_price }</td>
 84                                     <td style="CURSOR: hand; HEIGHT: 22px" align="center"
 85                                         width="17%">${pro.is_hot==1?"是":"否" }</td>
 86                                     <td align="center" style="HEIGHT: 22px"><a
 87                                         href="${ pageContext.request.contextPath }/EditProductServlet?pid=${pro.pid}">
 88                                             <img
 89                                             src="${pageContext.request.contextPath}/images/i_edit.gif"
 90                                             border="0" style="CURSOR: hand">
 91                                     </a></td>
 92 
 93                                     <td align="center" style="HEIGHT: 22px"><a href="javascript:void(0)" onClick="del(‘${pro.pid}‘)"> <img
 94                                             src="${pageContext.request.contextPath}/images/i_del.gif"
 95                                             width="16" height="16" border="0" style="CURSOR: hand">
 96                                     </a></td>
 97                                 </tr>
 98                             </c:forEach>
 99                         </table>
100                     </td>
101                 </tr>
102 
103             </TBODY>
104         </table>
105     </form>
106 </body>
107 </HTML>

黄色为添加的功能

技术图片

然后将这三个条件封装起来建实体类 Condition (条件)

 

Web 条件查询、分页查

标签:mouse   input   cin   hot   public   div   order   weight   sheet   

原文地址:https://www.cnblogs.com/zs0322/p/11180067.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!