首页 > 其他分享 >4.19每日总结

4.19每日总结

时间:2023-04-19 21:34:58浏览次数:32  
标签:总结 分页 pageSize 4.19 每日 num tempStr var endRow

今天完善了科技政策系统

<%@ page language= "java" contentType= "text/html; charset=UTF-8"%>
<!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" lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<%@ page import="java.sql.*"%>
<title>www.jb51.net JS分页</title>
<style type="">

td{
max-width: 320px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}</style>
<script>
/**
 * 分页函数
 * pno--页数
 * psize--每页显示记录数
 * 分页部分是从真实数据行开始,因而存在加减某个常数,以确定真正的记录数
 * 纯js分页实质是数据行全部加载,通过是否显示属性完成分页功能
 **/
function goPage(pno,psize){
  var itable = document.getElementById("idData");
  var num = itable.rows.length;//表格所有行数(所有记录数)
  console.log(num);
  var totalPage = 0;//总页数
  var pageSize = 12;//每页显示行数
  //总共分几页
  if(num/pageSize > parseInt(num/pageSize)){
      totalPage=parseInt(num/pageSize)+1;
    }else{
      totalPage=parseInt(num/pageSize);
    }
  var currentPage = pno;//当前页数
  var startRow = (currentPage - 1) * pageSize+1;//开始显示的行 31
    var endRow = currentPage * pageSize;//结束显示的行  40
    endRow = (endRow > num)? num : endRow;  //40
    console.log(endRow);
    //遍历显示数据实现分页
  for(var i=1;i<(num+1);i++){
    var irow = itable.rows[i-1];
    if(i>=startRow && i<=endRow){
      irow.style.display = "block";
    }else{
      irow.style.display = "none";
    }
  }
  var tempStr = "共"+num+"条记录 分"+totalPage+"页 当前第"+currentPage+"页";
  if(currentPage>1){
    tempStr += "<a href=\"#\" onClick=\"goPage("+(1)+","+psize+")\">首页</a>";
    tempStr += "<a href=\"#\" onClick=\"goPage("+(currentPage-1)+","+psize+")\"><上一页</a>"
  }else{
    tempStr += "首页";
    tempStr += "<上一页";
  }
  if(currentPage<totalPage){
    tempStr += "<a href=\"#\" onClick=\"goPage("+(currentPage+1)+","+psize+")\">下一页></a>";
    tempStr += "<a href=\"#\" onClick=\"goPage("+(totalPage)+","+psize+")\">尾页</a>";
  }else{
    tempStr += "下一页>";
    tempStr += "尾页";
  }
  document.getElementById("barcon").innerHTML = tempStr;
}
</script>
<script th:src="@{/layuimini/js/lay-module/echarts/echarts.js}"></script>
 <script th:src="@{/layuimini/js/lay-module/echarts/wordcloud.js}"></script>
<link rel="stylesheet" type="text/css" href="https://www.layuicdn.com/layui/css/layui.css" />
 <script src="https://www.layuicdn.com/layui/layui.js"></script>
</head>
<body onl oad="goPage(1,10);">
<div style="text-align:center;">
  <img src="LOGO.png" width="40" height="40" style="margin-right: 10px;">
  <span style="font-size: 35px; color:#1571b2;">科技政策查询系统</span>
</div>

<div   style="text-align:center;width:100%;height:65px;float:left; position:relative; display: table-cell;vertical-align: middle;  background-color: rgba(232,232,232,0.76) ">

    <form class="layui-form"action="test1.jsp" >
        <p> </p>
        <div class="layui-form-item">

            <div class="layui-inline">

                <label class="layui-form-label">
                    政策名称:
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="name"  class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">
                    政策文号:
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="document"  class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">
                    发文机构:
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="organ"  class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <button type="submit" class="layui-btn" lay-submit lay-filter="demo1"style="background-color: #1571b2">查询</button>
                </div>
            </div>
        </div>
    </form>
</div>
<div class="container3" id="container3">
<form action="test1.jsp">
<table id="idData"  border="1px" align="center" class="layui-table"style="table-layout: fixed;word-wrap:break-word;" >
 <thead>
        <tr align="center">
            <td style="width: 320px">政策名称</td>
            <td style="width:320px">发文机构</td>
            <td style="width: 320px">颁布日期</td>
            <td style="width:320px">政策分类</td>
   
        </tr>
        </thead>
<% 
String a=request.getParameter("name");
String b=request.getParameter("document");
String c=request.getParameter("organ");


String URL = "jdbc:mysql://localhost:3306/info ";
String USERNAME = "root";
String PWD = "PENGsuoqun123";

        //jsp就是在html中嵌套的java代码,因此java代码可以写在jsp中(《%%》)
    PreparedStatement pstmt = null;
    ResultSet rs=null;
            Connection connection = null;
            
            try {

                // a.导入驱动,加载具体驱动类

                Class.forName("com.mysql.cj.jdbc.Driver");//注册// 加载具体的驱动类
                // b.与数据库建立链接
                connection = DriverManager.getConnection(URL, USERNAME, PWD);
String sql ="select * from policy order by id desc"  ;

                pstmt=connection.prepareStatement(sql);
            
                
            
                                
                                
                                
                                
                                
                                
                                rs= pstmt.executeQuery();// 反回值,增删改了几条数据增删改用update
                                
                                
                                
                                while(rs.next()) {
                                    //政策名称
                                        String name=rs.getString("name");
                                         //发文机构
                                         String organ=rs.getString("organ");
                                         //颁布时间
                                         String pubdata=rs.getString("pubdata");
                                         //政策分类
                                         String type=rs.getString("type");
                                        
                                        
                                        %>
                                        
                            
                                    
                                        
                                        
                                <tbody>
                                        <tr align="center">
                                        <td style="width: 320px" title="<%=name %>"><a href="neirong.jsp?name=<%=name %>"><%out.print(name);%></td>
                                        
                                        <td style="width: 320px" title="<%=organ %>"><%out.print(organ);%></td>
                                        <td style="width: 320px" title="<%=pubdata %>"><%out.print(pubdata);%></td>
                                        
                                        <td  style="width: 320px" title="<%=type %>"><%out.print(type);%></td>
                                     
                                        
                                    </tr>
                                    
                                            <%}     

        

                
            }
             catch (ClassNotFoundException e) {
                e.printStackTrace();
                
            }
            catch (SQLException e) {
                e.printStackTrace();
            
            } 
            catch (Exception e) {
                e.printStackTrace();
            
            } 
            
            finally {
                // 关闭数据库
                try{//先开的后关
                    if(rs!=null)rs.close();
                    if(pstmt!=null)pstmt.close();// 对象.方法
                
                    if(connection!=null)connection.close();
                } 
                catch( SQLException e){
                    e.printStackTrace();
                
                }
                
                
            }



%>
</tbody>
</table>
</form>
</div>
  <table width="100%" align="center">
    <tr><td style="text-align:center;"><div id="barcon" name="barcon"></div></td></tr>
  </table>
</body>
</html>
<%@ page language= "java" contentType= "text/html; charset=UTF-8"%>
<!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" lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<%@ page import="java.sql.*"%>
<title>www.jb51.net JS分页</title>
<style type="">

td{
max-width: 320px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}</style>
<script>
/**
 * 分页函数
 * pno--页数
 * psize--每页显示记录数
 * 分页部分是从真实数据行开始,因而存在加减某个常数,以确定真正的记录数
 * 纯js分页实质是数据行全部加载,通过是否显示属性完成分页功能
 **/
function goPage(pno,psize){
  var itable = document.getElementById("idData");
  var num = itable.rows.length;//表格所有行数(所有记录数)
  console.log(num);
  var totalPage = 0;//总页数
  var pageSize = 12;//每页显示行数
  //总共分几页
  if(num/pageSize > parseInt(num/pageSize)){
      totalPage=parseInt(num/pageSize)+1;
    }else{
      totalPage=parseInt(num/pageSize);
    }
  var currentPage = pno;//当前页数
  var startRow = (currentPage - 1) * pageSize+1;//开始显示的行 31
    var endRow = currentPage * pageSize;//结束显示的行  40
    endRow = (endRow > num)? num : endRow;  //40
    console.log(endRow);
    //遍历显示数据实现分页
  for(var i=1;i<(num+1);i++){
    var irow = itable.rows[i-1];
    if(i>=startRow && i<=endRow){
      irow.style.display = "block";
    }else{
      irow.style.display = "none";
    }
  }
  var tempStr = "共"+num+"条记录 分"+totalPage+"页 当前第"+currentPage+"页";
  if(currentPage>1){
    tempStr += "<a href=\"#\" onClick=\"goPage("+(1)+","+psize+")\">首页</a>";
    tempStr += "<a href=\"#\" onClick=\"goPage("+(currentPage-1)+","+psize+")\"><上一页</a>"
  }else{
    tempStr += "首页";
    tempStr += "<上一页";
  }
  if(currentPage<totalPage){
    tempStr += "<a href=\"#\" onClick=\"goPage("+(currentPage+1)+","+psize+")\">下一页></a>";
    tempStr += "<a href=\"#\" onClick=\"goPage("+(totalPage)+","+psize+")\">尾页</a>";
  }else{
    tempStr += "下一页>";
    tempStr += "尾页";
  }
  document.getElementById("barcon").innerHTML = tempStr;
}
</script>
<script th:src="@{/layuimini/js/lay-module/echarts/echarts.js}"></script>
 <script th:src="@{/layuimini/js/lay-module/echarts/wordcloud.js}"></script>
<link rel="stylesheet" type="text/css" href="https://www.layuicdn.com/layui/css/layui.css" />
 <script src="https://www.layuicdn.com/layui/layui.js"></script>
</head>
<body onl oad="goPage(1,10);">
<div style="text-align:center;">
  <img src="LOGO.png" width="40" height="40" style="margin-right: 10px;">
  <span style="font-size: 35px; color:#1571b2;">科技政策查询系统</span>
</div>

<div   style="text-align:center;width:100%;height:65px;float:left; position:relative; display: table-cell;vertical-align: middle;  background-color: rgba(232,232,232,0.76) ">

    <form class="layui-form"action="jieguo1.jsp" method="post" target="hideIframe1" >
        <p> </p>
        <div class="layui-form-item">

            <div class="layui-inline">

                <label class="layui-form-label">
                    政策名称:
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="name"  class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">
                    政策文号:
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="document"  class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">
                    发文机构:
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="organ"  class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <button type="submit" class="layui-btn" lay-submit lay-filter="demo1"style="background-color: #1571b2">查询</button>
                </div>
            </div>
        </div>
    </form>
</div>
<div class="container3" id="container3">
<form action="jieguo1.jsp">
<table id="idData"  border="1px" align="center" class="layui-table"style="table-layout: fixed;word-wrap:break-word;" >
 <thead>
        <tr align="center">
            <td style="width: 320px">政策名称</td>
            <td style="width:320px">发文机构</td>
            <td style="width: 320px">颁布日期</td>
            <td style="width:320px">政策分类</td>
   
        </tr>
        </thead>
<% 
String a=request.getParameter("name");
String b=request.getParameter("document");
String c=request.getParameter("organ");


String URL = "jdbc:mysql://localhost:3306/info ";
String USERNAME = "root";
String PWD = "PENGsuoqun123";

        //jsp就是在html中嵌套的java代码,因此java代码可以写在jsp中(《%%》)
    PreparedStatement pstmt = null;
    ResultSet rs=null;
            Connection connection = null;
            
            try {

                // a.导入驱动,加载具体驱动类

                Class.forName("com.mysql.cj.jdbc.Driver");//注册// 加载具体的驱动类
                // b.与数据库建立链接
                connection = DriverManager.getConnection(URL, USERNAME, PWD);
String sql ="SELECT * FROM policy WHERE name LIKE ? AND document LIKE ? AND organ LIKE ? ORDER BY id DESC " ;
                
                pstmt=connection.prepareStatement(sql);
            
                pstmt.setString(1, "%"+a+"%");
                pstmt.setString(2, "%"+b+"%");
                pstmt.setString(3, "%"+c+"%");
            
                                
                                
                                
                                
                                
                                
                                rs= pstmt.executeQuery();// 反回值,增删改了几条数据增删改用update
                                
                                
                                
                                while(rs.next()) {
                                    //政策名称
                                        String name=rs.getString("name");
                                         //发文机构
                                         String organ=rs.getString("organ");
                                         //颁布时间
                                         String pubdata=rs.getString("pubdata");
                                         //政策分类
                                         String type=rs.getString("type");
                                        
                                        
                                        %>
                                        
                            
                                    
                                        
                                        
                                <tbody>
                                            <tr align="center">
                                        <td style="width: 320px" title="<%=name %>"><a href="neirong.jsp?name=<%=name %>"><%out.print(name);%></td>
                                        
                                        <td style="width: 320px" title="<%=organ %>"><%out.print(organ);%></td>
                                        <td style="width: 320px" title="<%=pubdata %>"><%out.print(pubdata);%></td>
                                        
                                        <td  style="width: 320px" title="<%=type %>"><%out.print(type);%></td>
                                     
                                        
                                    </tr>
                                    
                                            <%}     

        

                
            }
             catch (ClassNotFoundException e) {
                e.printStackTrace();
                
            }
            catch (SQLException e) {
                e.printStackTrace();
            
            } 
            catch (Exception e) {
                e.printStackTrace();
            
            } 
            
            finally {
                // 关闭数据库
                try{//先开的后关
                    if(rs!=null)rs.close();
                    if(pstmt!=null)pstmt.close();// 对象.方法
                
                    if(connection!=null)connection.close();
                } 
                catch( SQLException e){
                    e.printStackTrace();
                
                }
                
                
            }



%>
</tbody>
</table>
</form>
</div>
  <table width="100%" align="center">
    <tr><td style="text-align:center;"><div id="barcon" name="barcon"></div></td></tr>
  </table>
</body>
</html>
<%@ page language= "java" contentType= "text/html; charset=UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">


<head>
<meta charset="UTF-8" >
<%@ page import="java.sql.*"%>
<title>内容展示页面</title>
</head>
<body>
<table border="1px" align="center">
  <%
    String name= request.getParameter("name");
%>
<%out.print(name); %></td></tr>


<%
String URL = "jdbc:mysql://localhost:3306/info ";
String USERNAME = "root";
String PWD = "PENGsuoqun123";

        //jsp就是在html中嵌套的java代码,因此java代码可以写在jsp中(《%%》)
    PreparedStatement pstmt = null;
    ResultSet rs=null;
            Connection connection = null;
            
            try {

                // a.导入驱动,加载具体驱动类

                Class.forName("com.mysql.cj.jdbc.Driver");//注册// 加载具体的驱动类
                // b.与数据库建立链接
                connection = DriverManager.getConnection(URL, USERNAME, PWD);
                String sql ="select * from policy where name like ? " ;
                
                pstmt=connection.prepareStatement(sql);
            
                pstmt.setString(1, "%"+name+"%");
        
                                
                                
                                
                                
                                
                                
                                rs= pstmt.executeQuery();// 反回值,增删改了几条数据增删改用update
                                
                                
                                while(rs.next()) {
                                    //政策名称
                                        String text=rs.getString("text");
                                         
                                        
                                        
                                        out.print(text);}     

        

                
            }
             catch (ClassNotFoundException e) {
                e.printStackTrace();
                
            }
            catch (SQLException e) {
                e.printStackTrace();
            
            } 
            catch (Exception e) {
                e.printStackTrace();
            
            } 
            
            finally {
                // 关闭数据库
                try{//先开的后关
                    if(rs!=null)rs.close();
                    if(pstmt!=null)pstmt.close();// 对象.方法
                
                    if(connection!=null)connection.close();
                } 
                catch( SQLException e){
                    e.printStackTrace();
                
                }
                
                
            }








%>







</table>

</body>

 

 

标签:总结,分页,pageSize,4.19,每日,num,tempStr,var,endRow
From: https://www.cnblogs.com/louwangshayu/p/17334694.html

相关文章

  • 2023.4.19 那片段 像对未来留言
    加训大数据结构。「LG8528」[Ynoi2003]铃原露露lxl怎么一题多投,很坏啊!考虑哪些\((a_x,a_y)\)有约束力,一是\(a_z>a_x\)且\(a_z>a_y\),或者\(a_z<a_x\)且\(a_z<a_y\)。这也就相当于将\(l\in[L_l,R_l],r\in[L_r,R_r]\)的二元组\((l,r)\)均设为非法。对于一次询问,我......
  • 每日打卡-8.2
    一.问题描述输入一个长度为n的整数序列。接下来再输入m个询问,每个询问输入一对l,r。对于每个询问,输出原序列中从第l个数到第r个数的和。二.设计思路 直接套用模板即可三.流程图四.伪代码 1五.代码实现 1#include<iostream>usingnamespacestd;constintN=1000......
  • 4.19团队
     调用百度智能识别的接口,制作了安卓使用界面,实现了图片的导入和活体识别,但尚且无法完成准确快速的人脸识别。......
  • 每日打卡-8.1
    一.问题描述  输入一个n行m列的整数矩阵,再输入q个询问,每个询问包含四个整数x1,y2,x1,y2,表示一个子矩阵的左上角坐标和右下角坐标。  对于每个询问输出子矩阵中所有数的和。二.设计思路很典型的二维前缀模板题 先求前缀和,再利用公式ans=s[x2][y2]-s[x2][y1-1]-s[x......
  • 2022.4.19编程一小时打卡
    一、问题描述:设计一个类people,有保护数据成员:age(年龄,整型),name(姓名,string),行为成员:两个构造函数(一个默认,另一个有参数);默认析构函数;voidsetValue(intm,stringstr)给age和name赋值;有一个void类型的纯虚函数display()。设计一个学生类student,公有继承类people,有私有成员......
  • 4.19
    #include<iostream>usingnamespacestd;classPoint{public: voidsetX(intX){ x=X; } intgetX(){ returnx; } voidsetY(intY){ y=Y; } intgetY(){ returny; }private: intx;inty;};classcircle{public: voidsetR(intR){ r=R; } intg......
  • 4.19 1.3
    一、问题描述从1990年1月1日开始三天打鱼两天晒网,以后的某一天是打鱼还是晒网?二、分析1、计算1.1到指定天数有几天2、周期为5天,用天数除以53、用余数判断是打鱼还是晒网123都为打鱼,40为晒网先利用循环求出1.1到指定天数有几天,还要考虑闰年情况(闰年二月29天,平年二月28天......
  • 4.19总结
    SQL学习一、1.注释:单行--或者#注释内容(Mysql特有)--注意空格多行注释/*注释*/showdatabases;--查询当前Mysql下有多少个数据库的名称。Mysql数据库的SQL语句不区分大小写,关键字建议使用大写。二、数据库的创建createdatabasesdb1;--创建dropdatabasesdb1......
  • 4.19打卡
    一、问题描述:对N个整数(数据由键盘输入)进行升序排列。二、设计思路:对于N个数因其类型相同,我们可利用数组进行存储。冒泡排序是在两个相邻元素之间进行比较交换的过程将一个无序表变成有序表。冒泡排序的思想:首先,从表头开始往后扫描数组,在扫描过程中逐对比较相邻两个元素的大小。......
  • 每日打卡1,(2)
    1.2借书方案知多少include<bits/stdc++.h> //万能开头usingnamespacestd;  #defineintlonglong  //防止爆intintn; signedmain(){             inti=0;for(inta=1;a<=5;a++){for(intb=1;b<=5;b++){if(a!=b)//前两比较减少......