JSTL分类查询

index.jsp

  1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
  2 <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
  3 <%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
  4 <%
  5     String path = request.getContextPath();
  6     String basePath = request.getScheme() + "://"
  7             + request.getServerName() + ":" + request.getServerPort()
  8             + path + "/";
  9 %>
 10
 11 <!DOCTYPE HTML>
 12 <html>
 13 <head>
 14     <base href="<%=basePath%>">
 15     <title>账单管理</title>
 16     <meta http-equiv="pragma" content="no-cache">
 17     <meta http-equiv="cache-control" content="no-cache">
 18     <meta http-equiv="expires" content="0">
 19     <script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
 20     <style>
 21         table{width:700px;}
 22         table ,tr ,td, th
 23          {
 24              text-align: center;
 25              border:1px black solid;
 26              border-collapse:collapse;
 27          }
 28          .setGreen{background-color: green;}
 29          .over{background-color:#f9360d;}
 30          span{font-weigh:bold;color:red;}
 31     </style>
 32     <script>
 33         function setTableColor()
 34         {
 35             var table = $("#showTable")[0];
 36             for(var i = 0; i < table.rows.length; i++)
 37             {
 38                 if(i % 2 == 0)
 39                 {
 40                     table.rows[i].className = "setGreen";
 41                 }
 42                 var name;
 43                 table.rows[i].onmouseover = function()
 44                 {
 45                     name = this.className;
 46                     this.className = "over";
 47                 }
 48                 table.rows[i].onmouseout = function()
 49                 {
 50                     this.className = name;
 51                 }
 52             }
 53         }
 54         $(
 55             function loadType()
 56             {
 57                 var select = $("#bookClass");
 58                 select.html("<option value=‘0‘>不限</option>");
 59                 $.ajax
 60                 ({
 61                     url:"type_query",
 62                     type:"post",
 63                     dataType:"json",
 64                     success:function(data)
 65                     {
 66                         var types = data.typeList;
 67                         for(var i = 0; i < types.length; i++)
 68                         {
 69                             var option = "<option value=‘"+types[i].id+"‘>"+types[i].name+"</option>";
 70                             select.append(option);
 71                         }
 72                     },
 73                     error:function()
 74                     {
 75                         alert("服务器忙!");
 76                     }
 77                 });
 78             }
 79         );
 80         function checkTime(timeInput)
 81         {
 82             var time = timeInput.value;
 83             var regTime = /^(\d{4})-(0\d{1}|1[0-2])-(0\d{1}|[12]\d{1}|3[01])$/;
 84             var error = $("#error");
 85             error.html("");
 86             if(regTime.test(time) || time == "")
 87             {
 88                 return true;
 89             }
 90             error.html("日期格式不正确!(yyyy-MM-dd)");
 91             return false;
 92         }
 93         function checkAll()
 94         {
 95             if(checkTime($("#begintime")[0]) && checkTime($("#endtime")[0]))
 96             {
 97                 return true;
 98             }
 99             return false;
100         }
101     </script>
102 </head>
103 <body>
104     <div align="center">
105         <h1>账单管理系统</h1>
106         <form action="bill_query" method="post" onsubmit="return checkAll();">
107         类型:<select id="bookClass" name="typeid"></select>&nbsp;
108         时间:<input type="text" id="begintime" name="begintime" onblur="checkTime(this);" />&nbsp;到&nbsp;
109         <input type="text" id="endtime" name="endtime" onblur="checkTime(this);" />&nbsp;
110         <input type="submit" id="query" value="搜索" onclick="query(1,10);" />
111         <input type="button" value="记账" onclick="javascript:window.location=‘record.jsp‘" /></br>
112         </br></form>
113         <table id="showTable">
114             <tr><th>行号</th><th>标题</th><th>记账时间</th><th>类别</th><th>金额</th><th>说明</th></tr>
115             <c:forEach items="${billList}" var="each" varStatus="status">
116                 <tr>
117                     <td>${status.count}</td>
118                     <td>${each.title}</td>
119                     <td>${each.billtime}</td>
120                     <td>
121                         <c:forEach items="${typeList}" var="type">
122                             <c:if test="${each.typeid == type.id}">
123                                 ${type.name}
124                             </c:if>
125                         </c:forEach>
126                     </td>
127                     <td>${each.price}</td>
128                     <td>${each.remark}</td>
129                 </tr>
130             </c:forEach>
131             <c:if test="${billList == null || fn:length(billList) == 0}">
132                 <tr><td colspan="6"><h3>没有查到任何数据!</h3></td></tr>
133             </c:if>
134             <c:if test="true">
135                 <script>setTableColor();</script>
136             </c:if>
137         </table>
138         <span><h3 id="error"></h3></span>
139     </div>
140 </body>
141 </html>

时间: 2024-10-14 15:25:45

JSTL分类查询的相关文章

Goods:图书模块按分类查询各层实现

BookDao 1 //按分类查询 2 public PageBean<Book> findByCategory(String cid,int pc) throws SQLException 3 { 4 List<Expression> exprList=new ArrayList<Expression>(); 5 exprList.add(new Expression("cid", "=", cid)); 6 return fi

最基础的PHP分类查询程序

最初级的PHP分类查询程序 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv=

SQL 语句与性能之联合查询和联合分类查询

select * from t1 left join t2 on t2.sysno =t1.ASysNo left join t3 on t3.sysno =t2.ASysNo left join t4 on t4.sysno =t3.ASysNo left join t5 on t5.sysno =t4.ASysNo left join t6 on t6.sysno =t5.ASysNo left join t7 on t7.sysno =t6.ASysNo where t1.name lik

SQL处理多级分类,查询结果呈树形结构

对于多级分类常规的处理方法,很多程序员可能是用程序先读取一级分类记录,然后通过一级分类循环读取下面的子分类 这样处理的弊端是:如果数据量大,子分类很多,达到4级以上,这方法处理极端占用数据库连接池 对性能影响很大. 如果用SQL下面的CTE递归处理的话,一次性就能把结果给查询出来,而且性能很不错 比用程序处理(数据量很大的情况),临时表性能更好,更方便 with area as(select *,id px,cast(id as nvarchar(4000)) px2 from region w

无限极分类查询

From:http://www.cnblogs.com/smailxiaobai/archive/2012/01/13/2321850.html --建立一个数据表 这可以是你的一个物理表 declare @temp table( ID varchar(20), ParentID varchar(20), Name nvarchar(100)) insert into @temp values('A','','分类A') insert into @temp values('B','','分类B'

ThinkPHP分类查询(获取当前分类的子分类,获取父分类,下一级分类)

获取指定分类的所有子分类ID号 //获取指定分类的所有子分类ID号 function getAllChildcateIds($categoryID){ //初始化ID数组 $array[] = $categoryID; do { $ids = ''; $where['pid'] = array('in',$categoryID); $cate = M('cate')->where($where)->select(); foreach ($cate as $k=>$v){ $array[]

MySQL 获取某一个分类ID的所有父或子分类查询结果

创建一个自定义函数: 1 DELIMITER $$ 2 3 USE `dressv_website`$$ 4 5 DROP FUNCTION IF EXISTS `fn_QueryRelation`$$ 6 7 CREATE DEFINER=`sa`@`%` FUNCTION `fn_QueryRelation`(AreaId INT,Relation TINYINT(1)) RETURNS VARCHAR(4000) CHARSET utf8 8 BEGIN 9 DECLARE sTemp V

一张表按分类查询:只显示前2行

描述:按登录用户名称查询:登录用户有用很多.按登录用户进行筛选,并每个登录用户类只显示前2行 sql代码 select * from sys_user_login_log s where 2>(select count(*) from sys_user_login_log WHERE login_name=s.login_name AND id<s.id) order by login_name;

mysql 多表分类查询 好大上啊!

一.三张表进行查询 二.两张表通过范围查