4月13日笔记
河北省科技政策系统
layouts.html
<!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:65px;float:left; position:relative; display: table-cell;vertical-align: middle; background-color: rgba(232,232,232,0.76) "> <form class="layui-form"action="table.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"> <iframe id="myIframe1" name="hideIframe1" style="" src="table.jsp" frameborder="0" width="100%" height="850px"></iframe> </div> </body> </html>
dao包
package Dao; import Bean.bean; import DBUtil.dbutil; import java.sql.*; import java.util.ArrayList; import java.util.List; public class dao { public List<bean> searchAll( ){ List<bean> list = new ArrayList<bean>(); try { Connection conn = dbutil.getConn(); String sql="select * from policy order by pubdata DESC"; PreparedStatement pstmt = conn.prepareStatement(sql); ResultSet rs = pstmt.executeQuery(); System.out.println("搜索全部政策"); while(rs.next()){ bean lu = new bean(); lu.setId(rs.getString("id")); lu.setType(rs.getString("type")); lu.setOrgan(rs.getString("organ")); lu.setPubdata(rs.getString("pubdata")); lu.setName(rs.getString("name")); list.add(lu); } rs.close(); pstmt.close(); conn.close(); }catch(SQLException e) { System.out.println("发生错误"); e.printStackTrace(); } return list; } public List<bean> search(String name,String document,String organ){ List<bean> list = new ArrayList<bean>(); try { Connection conn = dbutil.getConn(); String sql = "select * from policy where "; if (name != "") { sql += "name like '%" + name + "%'"; } else if (document != "") { sql += "document like '%" + document + "%'"; } else if (organ != "") { sql += "organ like '%" + organ + "%'"; } else { } //String sql = "select * from policy where name = '"+name+"' or document = '"+document+"' or organ = '"+organ+"'"; sql+="order by pubdata DESC"; PreparedStatement pstmt = conn.prepareStatement(sql); ResultSet rs = pstmt.executeQuery(); System.out.println("多项条件搜索运行中"); while(rs.next()){ bean lu = new bean(); lu.setId(rs.getString("id")); lu.setType(rs.getString("type")); lu.setOrgan(rs.getString("organ")); lu.setPubdata(rs.getString("pubdata")); lu.setName(rs.getString("name")); lu.setDocument(rs.getString("document")); list.add(lu); } rs.close(); pstmt.close(); conn.close(); }catch(SQLException e) { System.out.println("发生错误"); e.printStackTrace(); } return list; } }

浙公网安备 33010602011771号