学习记录(4.11)
学习时长:8h
代码行数:约400行
昨天进行了极限挑战,完成的并不好,回宿舍后重新整理思绪,今天进行了重写,废话也不多说了,直接上代码和截图吧
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | <%@ page language= "java" contentType= "text/html; charset=UTF-8" pageEncoding= "UTF-8" %> <!DOCTYPE html> <html> <head> <meta charset= "UTF-8" > <title>Insert title here</title> </head> <body> <h1 style= "text-align: center;" ></h1> <br> <% String name = request.getParameter( "name" ); session.setAttribute( "name" ,name); String id = request.getParameter( "id" ); session.setAttribute( "id" ,id); String organ = request.getParameter( "organ" ); session.setAttribute( "organ" ,organ); %> <div style= "text-align: center" >河北省科学技术情报研究院 河北省科技创新战略研究院 技术支持:河北省科技信息处理实验室。</div> <jsp:forward page = "table1.jsp" /> </body> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | <%@ page language= "java" contentType= "text/html; charset=UTF-8" pageEncoding= "UTF-8" %> <!DOCTYPE html> <html lang= "en" xmlns:th= "http://www.thymeleaf.org" > <head> <meta charset= "UTF-8" > <title>Title</title> <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> <div style= "width:100%;height:90px; background-color:white ;" > <div style= "width:100%;height:65px;float:left; position:relative; display: table-cell;vertical-align: middle; background-color: rgba(232,232,232,0.76) " > <form action= "findallnew1.jsp" method= "get" target= "hideIframe1" > <p> </p> <div class = "layui-form-item" > <img alt= "LOGO" src= "img/LOGO.png" style= "width: 50px" /> <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= "id" 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" > <center><button type= "submit" class = "layui-btn" lay-submit lay-filter= "demo1" >查询</button></center> </div> </div> </div> </form> </div> </br> </br> </br> </br> </br> <div class = "container3" > <iframe id= "myIframe1" name= "hideIframe1" style= "" src= "table1.jsp" frameborder= "0" width= "100%" height= "850px" ></iframe> </div> <div style= "text-align: center" >版权所有:河北省科学技术情报研究院 河北省科技创新战略研究院 技术支持:河北省科技信息处理实验室。</div> </body> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | <%@ page contentType= "text/html;charset=UTF-8" language= "java" %> <%@ page import = "java.util.List" %> <%@ page import = "java.sql.Connection" %> <%@ taglib prefix= "fn" uri= "http://java.sun.com/jsp/jstl/functions" %> <%@ page import = "java.sql.PreparedStatement" %> <%@ page import = "java.sql.SQLException" %> <%@ page import = "java.sql.Statement" %> <%@ page import = "java.sql.ResultSet" %> <%@ taglib uri= "http://java.sun.com/jsp/jstl/core" prefix= "c" %> <!DOCTYPE html> <html lang= "en" xmlns:th= "http://www.thymeleaf.org" > <head> <meta charset= "UTF-8" > <title>Title</title> <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> <% java.sql.Connection sqlCon; //数据库连接对象 java.sql.Statement sqlStmt; //SQL语句对象 java.sql.ResultSet sqlRst; //结果集对象 java.lang.String strCon; //数据库连接字符串 java.lang.String strSQL; //SQL语句 int intPageSize; //一页显示的记录数 int intRowCount; //记录总数 int intPageCount; //总页数 int intPage; //待显示页码 java.lang.String strPage; String name = (String) session.getAttribute( "name" ); String id = (String) session.getAttribute( "id" ); String organ = (String) session.getAttribute( "organ" ); int i=0; //设置一页显示的记录数 intPageSize = 10; int sum=0; //取得待显示页码 strPage = request.getParameter( "page" ); if (strPage== null ){ //表明在QueryString中没有page这一个参数,此时显示第一页数据 intPage = 1; } else { //将字符串转换成整型 intPage =java.lang.Integer.parseInt(strPage); if (intPage<1) intPage = 1; } Class.forName( "com.mysql.cj.jdbc.Driver" ).newInstance(); String username = "root" ; //用户名 String password = "123456" ; //密码 String url= "jdbc:mysql://localhost:3306/zhengce?useUnicode=true&characterEncoding=UTF-8" ; //连接数据库 sqlCon=java.sql.DriverManager.getConnection(url,username,password); //创建语句对象 sqlStmt =sqlCon.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY); //创建查询语句 strSQL = "select * from policy where id like '%" + id + "%' and name like '%" + name + "%' and organ like '%" + organ + "%'" ; //执行SQL语句并获取结果集 sqlRst = sqlStmt.executeQuery(strSQL); //获取记录总数 sqlRst.last(); sum=sqlRst.getRow(); intRowCount = sqlRst.getRow(); //记算总页数 intPageCount = (intRowCount+intPageSize-1) /intPageSize; //调整待显示的页码 if (intPage>intPageCount) intPage = intPageCount; %> <table class = "layui-table" style= "table-layout: fixed;word-wrap:break-word;" style= "text-overflow:ellipsis;" > <thead> <tr> <td style= "width: 300px" >政策名称</td> <td style= "width: 150px" >发文机构</td> <td style= "width: 70px" >颁布日期</td> <td style= "width: 80px" >政策分类</td> </tr> <% if (intPageCount>0) { //将记录指针定位到待显示页的第一条记录上 sqlRst.absolute((intPage-1)* intPageSize + 1); //显示数据 i = 0; while (i<intPageSize &&!sqlRst.isAfterLast()){ String namea=sqlRst.getString( "name" ); String organa=sqlRst.getString( "organ" ); String pubdataa=sqlRst.getString( "pubdata" ); String typea=sqlRst.getString( "type" ); %> <style type= "text/css" > .box{ width: 600px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; } </style> <style type= "text/css" > .box1{ width: 300px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; } </style> <tr> <td><div class = "box" title=<%=namea%>><a href= 'xiangqing.jsp?namea=<%=sqlRst.getString("name")%>' %><%=namea%></a></div></td> <td><div class = "box1" title=<%=organa%>><%=(sqlRst.getString( "organ" )) %></div></td> <td><%=(sqlRst.getString( "pubdata" )) %></td> <td><%=typea %></td> </tr> <% sqlRst.next(); i++; } } %> </thead> </table> <center> 共<%=sum %>条 第<%=intPage%>页 共<%=intPageCount%>页 <% //以下是分页的“上一页”“下一页”,有上一页就有链接,没有就为文字,下一页同理%> <% if (intPage>1){ %> <a href= "table1.jsp?page=<%=intPage-1%>" >[上一页]</a> <% } else { %> [上一页] <%}%> <% if (intPage<intPageCount){ %> <a href= "table1.jsp?page=<%=intPage+1%>" >[下一页]</a> <% } else { %> [下一页] <%}%> <center> <% //关闭结果集 sqlRst.close(); //关闭SQL语句对象 sqlRst.close(); //关闭数据库 sqlRst.close(); %> <div style= "text-align: center" >版权所有:河北省科学技术情报研究院 河北省科技创新战略研究院 技术支持:河北省科技信息处理实验室。</div> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | <%@ page contentType= "text/html;charset=UTF-8" language= "java" %> <%@ page import = "java.util.List" %> <%@ page import = "java.sql.Connection" %> <%@ taglib prefix= "fn" uri= "http://java.sun.com/jsp/jstl/functions" %> <%@ page import = "java.sql.PreparedStatement" %> <%@ page import = "java.sql.SQLException" %> <%@ page import = "java.sql.Statement" %> <%@ page import = "java.sql.ResultSet" %> <%@ taglib uri= "http://java.sun.com/jsp/jstl/core" prefix= "c" %> <!DOCTYPE html> <html lang= "en" xmlns:th= "http://www.thymeleaf.org" > <head> <meta charset= "UTF-8" > <title>Title</title> <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> <% java.sql.Connection sqlCon; //数据库连接对象 java.sql.Statement sqlStmt; //SQL语句对象 java.sql.ResultSet sqlRst; //结果集对象 java.lang.String strCon; //数据库连接字符串 java.lang.String strSQL; //SQL语句 int intPageSize; //一页显示的记录数 int intRowCount; //记录总数 int intPageCount; //总页数 int intPage; //待显示页码 java.lang.String strPage; Class.forName( "com.mysql.cj.jdbc.Driver" ).newInstance(); String username = "root" ; //用户名 String password = "123456" ; //密码 String url= "jdbc:mysql://localhost:3306/zhengce?useUnicode=true&characterEncoding=UTF-8" ; //连接数据库 sqlCon=java.sql.DriverManager.getConnection(url,username,password); //创建语句对象 sqlStmt =sqlCon.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY); //创建查询语句 String sql = "select * from policy" ; String namea = (String)request.getParameter( "namea" ); strSQL = "select * from policy where name like '%" +namea+ "%'" ; //执行SQL语句并获取结果集 sqlRst = sqlStmt.executeQuery(strSQL); sqlRst.last(); %> <td><div style= "font-size:20pt" ><center><%=(sqlRst.getString( "name" )) %></center></div></td> <table class = "layui-table" style= "table-layout: fixed;word-wrap:break-word;" style= "text-overflow:ellipsis;" > <thead> <tr> <td style= "width: 70px" >范围</td> <td style= "width: 150px" >发文机构</td> <td style= "width: 70px" >颁布日期</td> <td style= "width: 80px" >政策分类</td> </tr> <style type= "text/css" > .box{ width: 600px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; } </style> <tr> <td><%=(sqlRst.getString( "range" )) %></td> <td><%=(sqlRst.getString( "organ" )) %></td> <td><%=(sqlRst.getString( "pubdata" )) %></td> <td><%=(sqlRst.getString( "type" )) %></td> </tr> </thead> </table> <td><center><%=(sqlRst.getString( "text" )) %></center></td> <% //关闭结果集 sqlRst.close(); //关闭SQL语句对象 sqlRst.close(); //关闭数据库 sqlRst.close(); %> <div style= "text-align: center" >版权所有:河北省科学技术情报研究院 河北省科技创新战略研究院 技术支持:河北省科技信息处理实验室。</div> </html> |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 提示词工程——AI应用必不可少的技术
· 字符编码:从基础到乱码解决
· 地球OL攻略 —— 某应届生求职总结