期刊论文在线投稿审稿系统⑤(总编功能页)
一、功能
二、效果如下
三、代码如下
ChiefEditor.jsp
1 <%@ page language="java" contentType="text/html; charset=UTF-8" 2 pageEncoding="UTF-8"%> 3 <!DOCTYPE html> 4 <html> 5 <head> 6 <meta charset="UTF-8"> 7 <title>总编功能页</title> 8 <link rel="stylesheet" href=".//layui/css/layui.css" media="all"> 9 <script src=".//layui/layui.all.js"></script> 10 <script src=".//layui/layui.js"></script> 11 <script type="text/javascript"> 12 //JavaScript代码区域 13 layui.use('element', function() { 14 var element = layui.element; 15 }); 16 </script> 17 </head> 18 <body class="layui-layout-body"> 19 20 <div class="layui-layout layui-layout-admin"> 21 <div class="layui-header"> 22 <div class="layui-logo"> 23 <% 24 String identity = (String) session.getAttribute("identity"); 25 out.print(identity); 26 %> 27 功能页欢迎 28 <% 29 String username = (String) session.getAttribute("username"); 30 out.print(username); 31 %> 32 </div> 33 <!-- 水平导航 --> 34 <ul class="layui-nav layui-layout-right"> 35 <li class="layui-nav-item "><a href="index.jsp">退出</a></li> 36 </ul> 37 </div> 38 39 <div class="layui-side layui-bg-black"> 40 <div class="layui-side-scroll"> 41 <!-- 左侧导航 --> 42 <ul class="layui-nav layui-nav-tree"> 43 <li class="layui-nav-item"><a 44 href="ChiefServlet?method=ChiefEditor_gaojianqianfa" 45 target="frame">稿件签发</a></li> 46 <li class="layui-nav-item"><a 47 href="ChiefEditor_chaxungaojian.jsp" target="frame">查询稿件</a></li> 48 <li class="layui-nav-item"><a 49 href="ChiefServlet?method=ChiefEditor_chehuigaojian" 50 target="frame">撤回稿件</a></li> 51 </ul> 52 </div> 53 </div> 54 <div class="layui-body"> 55 <!-- 内容主体区域 --> 56 <iframe name="frame" width="100%" height="100%" 57 style="border: 1px solid #CCC;"></iframe> 58 </div> 59 <div> 60 <div> 61 <input type="text" id="date" /> 62 </div> 63 </div> 64 </div> 65 </body> 66 </html>
ChiefEditor_gaojianqianfa.jsp
1 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 2 <%@ page language="java" contentType="text/html; charset=UTF-8" 3 pageEncoding="UTF-8"%> 4 <!DOCTYPE html> 5 <html> 6 <head> 7 <meta charset="UTF-8"> 8 <title>稿件签发</title> 9 <link rel="stylesheet" href=".//layui/css/layui.css" media="all"> 10 <script src=".//layui/layui.all.js"></script> 11 <script src=".//layui/layui.js"></script> 12 </head> 13 <body> 14 <table class="layui-table"> 15 <thead> 16 <tr> 17 <th>id</th> 18 <th>中文标题</th> 19 <th>审稿人1</th> 20 <th>审稿人1意见</th> 21 <th>审稿人2</th> 22 <th>审稿人2意见</th> 23 <th>审稿人3</th> 24 <th>审稿人3意见</th> 25 <th>操作</th> 26 </tr> 27 </thead> 28 <tbody> 29 <c:forEach items="${list}" var="storysituation" varStatus="status"> 30 <tr> 31 <td>${ status.index + 1}</td> 32 <td>${storysituation.ctitle}</td> 33 <td>${storysituation.name_one_agree}</td> 34 <td>${storysituation.name_one_opinion}</td> 35 <td>${storysituation.name_two_agree}</td> 36 <td>${storysituation.name_two_opinion}</td> 37 <td>${storysituation.name_three_agree}</td> 38 <td>${storysituation.name_three_opinion}</td> 39 <td><button class="layui-btn layui-btn-normal" 40 onclick="window.location.href='ChiefServlet?method=gaojianqianfa_check&ctitle=${storysituation.ctitle}'">查看详情</button></td> 41 </tr> 42 </c:forEach> 43 </tbody> 44 </table> 45 </body> 46 </html>
ChiefEditor_gaojianqianfa_check.jsp
1 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 2 <%@ page language="java" contentType="text/html; charset=UTF-8" 3 pageEncoding="UTF-8"%> 4 <!DOCTYPE html> 5 <html> 6 <head> 7 <meta charset="UTF-8"> 8 <title>稿件签发</title> 9 <link rel="stylesheet" href=".//layui/css/layui.css" media="all"> 10 <script src=".//layui/layui.all.js"></script> 11 <script src=".//layui/layui.js"></script> 12 </head> 13 <body> 14 <c:forEach items="${list}" var="storysituation"> 15 <div> 16 <label>中文标题:</label> <label>${storysituation.ctitle}</label> 17 </div> 18 <div> 19 <label>审签是否同意:</label> <label>${storysituation.shenqianAgree}</label> 20 </div> 21 <div> 22 <label>审签意见:</label> <label>${storysituation.shenqianOpinion}</label> 23 </div> 24 <div> 25 <label>查重结果:</label> <label>${storysituation.chachongResult}</label> 26 </div> 27 <div> 28 <label>审签人1是否同意:</label> <label>${storysituation.name_one_agree}</label> 29 </div> 30 <div> 31 <label>审签人1意见:</label> <label>${storysituation.name_one_opinion}</label> 32 </div> 33 <div> 34 <label>审签人2是否同意:</label> <label>${storysituation.name_two_agree}</label> 35 </div> 36 <div> 37 <label>审签人2意见:</label> <label>${storysituation.name_two_opinion}</label> 38 </div> 39 <div> 40 <label>审签人3是否同意:</label> <label>${storysituation.name_three_agree}</label> 41 </div> 42 <div> 43 <label>审签人3意见:</label> <label>${storysituation.name_three_opinion}</label> 44 </div> 45 <div> 46 <button class="layui-btn layui-btn-normal" 47 onclick="window.location.href='ChiefServlet?method=gaojianqianfa_checkResult&IsAgree=Agree'">同意签发</button> 48 <button class="layui-btn layui-btn-normal" 49 onclick="window.location.href='ChiefServlet?method=gaojianqianfa_checkResult&IsAgree=DisAgree'">不同意签发</button> 50 </div> 51 </c:forEach> 52 </body> 53 </html>
ChiefEditor_chehuigaojian.jsp
1 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 2 <%@ page language="java" contentType="text/html; charset=UTF-8" 3 pageEncoding="UTF-8"%> 4 <!DOCTYPE html> 5 <html> 6 <head> 7 <meta charset="UTF-8"> 8 <title>撤回稿件</title> 9 <link rel="stylesheet" href=".//layui/css/layui.css" media="all"> 10 <script src=".//layui/layui.all.js"></script> 11 <script src=".//layui/layui.js"></script> 12 </head> 13 <body> 14 <table class="layui-table"> 15 <thead> 16 <tr> 17 <th>id</th> 18 <th>中文标题</th> 19 <th>用户意见</th> 20 <th>操作</th> 21 </tr> 22 </thead> 23 <tbody> 24 <c:forEach items="${list}" var="storysituation" varStatus="status"> 25 <tr> 26 <td>${ status.index + 1}</td> 27 <td>${storysituation.ctitle}</td> 28 <td>${storysituation.user_oppose_opinion}</td> 29 <td><button class="layui-btn layui-btn-normal" 30 onclick="window.location.href='ChiefServlet?method=withdraw&ctitle=${storysituation.ctitle}'">撤回</button></td> 31 </tr> 32 </c:forEach> 33 </tbody> 34 </table> 35 </body> 36 </html>
ChiefEditor_chaxungaojian.jsp
1 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 2 <%@ page language="java" contentType="text/html; charset=UTF-8" 3 pageEncoding="UTF-8"%> 4 <!DOCTYPE html> 5 <html> 6 <head> 7 <meta charset="UTF-8"> 8 <title>查询稿件</title> 9 <link rel="stylesheet" href=".//layui/css/layui.css" media="all"> 10 <script src=".//layui/layui.all.js"></script> 11 <script src=".//layui/layui.js"></script> 12 </head> 13 <body> 14 <form class="layui-form" action="ChiefServlet?method=chaxungaojian" 15 method="post"> 16 <div class="layui-form-item"> 17 <label class="layui-form-label">中文标题</label> 18 <div class="layui-inline"> 19 <input type="text" class="layui-input" name="ctitle"> 20 </div> 21 </div> 22 <div class="layui-form-item"> 23 <label class="layui-form-label">中文关键字</label> 24 <div class="layui-inline"> 25 <input type="text" class="layui-input" name="ckey"> 26 </div> 27 </div> 28 <div class="layui-form-item"> 29 <label class="layui-form-label">中文摘要</label> 30 <div class="layui-inline"> 31 <input type="text" class="layui-input" name="cabstract"> 32 </div> 33 </div> 34 <div class="layui-form-item"> 35 <label class="layui-form-label">作者名称</label> 36 <div class="layui-inline"> 37 <input type="text" class="layui-input" name="name"> 38 </div> 39 <div class="layui-inline"> 40 <button class="layui-btn" lay-submit>查询</button> 41 </div> 42 </div> 43 </form> 44 <table class="layui-table"> 45 <thead> 46 <tr> 47 <th>id</th> 48 <th>中文标题</th> 49 <th>中文摘要</th> 50 <th>中文关键字</th> 51 <th>内容</th> 52 <th>接收状态</th> 53 <th>投稿人</th> 54 </tr> 55 </thead> 56 <tbody> 57 <c:forEach items="${list}" var="story" varStatus="status"> 58 <tr> 59 <td>${ status.index + 1}</td> 60 <td>${story.ctitle}</td> 61 <td>${story.cabstract}</td> 62 <td>${story.ckey}</td> 63 <td>${story.content}</td> 64 <td>${story.receiver}</td> 65 <td>${story.name}</td> 66 </tr> 67 </c:forEach> 68 </tbody> 69 </table> 70 </body> 71 </html>
ChiefServlet.java(在servlet文件下建立此java文件)
1 package servlet; 2 3 import java.io.IOException; 4 import java.util.List; 5 6 import javax.servlet.ServletException; 7 import javax.servlet.annotation.WebServlet; 8 import javax.servlet.http.HttpServlet; 9 import javax.servlet.http.HttpServletRequest; 10 import javax.servlet.http.HttpServletResponse; 11 import javax.servlet.http.HttpSession; 12 import javax.swing.JOptionPane; 13 14 import dao.ChiefDao; 15 import util.Story; 16 import util.StorySituation; 17 18 /** 19 * Servlet implementation class ChiefServlet 20 */ 21 @WebServlet("/ChiefServlet") 22 public class ChiefServlet extends HttpServlet { 23 private static final long serialVersionUID = 1L; 24 25 /** 26 * @see HttpServlet#HttpServlet() 27 */ 28 public ChiefServlet() { 29 super(); 30 // TODO Auto-generated constructor stub 31 } 32 33 ChiefDao dao = new ChiefDao(); 34 35 /** 36 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse 37 * response) 38 */ 39 protected void doGet(HttpServletRequest request, HttpServletResponse response) 40 throws ServletException, IOException { 41 // TODO Auto-generated method stub 42 // response.getWriter().append("Served at: ").append(request.getContextPath()); 43 doPost(request, response); 44 } 45 46 /** 47 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse 48 * response) 49 */ 50 protected void doPost(HttpServletRequest request, HttpServletResponse response) 51 throws ServletException, IOException { 52 // TODO Auto-generated method stub 53 // doGet(request, response); 54 55 response.setCharacterEncoding("UTF-8"); 56 request.setCharacterEncoding("UTF-8"); 57 System.out.println("进入ChiefServlet"); 58 String method = request.getParameter("method"); 59 System.out.println(method); 60 if ("ChiefEditor_gaojianqianfa".equals(method)) { 61 ChiefEditor_gaojianqianfa(request, response); 62 } else if ("gaojianqianfa_check".equals(method)) { 63 gaojianqianfa_check(request, response); 64 } else if ("gaojianqianfa_checkResult".equals(method)) { 65 gaojianqianfa_checkResult(request, response); 66 } else if ("ChiefEditor_chehuigaojian".equals(method)) { 67 ChiefEditor_chehuigaojian(request, response); 68 } else if ("withdraw".equals(method)) { 69 withdraw(request, response); 70 } else if ("chaxungaojian".equals(method)) { 71 chaxungaojian(request, response);// 查询稿件 72 } 73 } 74 75 public void ChiefEditor_gaojianqianfa(HttpServletRequest request, HttpServletResponse response) 76 throws ServletException, IOException { 77 response.setCharacterEncoding("UTF-8"); 78 request.setCharacterEncoding("UTF-8"); 79 80 List<StorySituation> list = dao.gaojianqianfa(); 81 request.setAttribute("list", list); 82 request.getRequestDispatcher("ChiefEditor_gaojianqianfa.jsp").forward(request, response); 83 84 } 85 86 public void gaojianqianfa_check(HttpServletRequest request, HttpServletResponse response) 87 throws ServletException, IOException { 88 response.setCharacterEncoding("UTF-8"); 89 request.setCharacterEncoding("UTF-8"); 90 91 String ctitle = request.getParameter("ctitle"); 92 93 // 使用request对象的getSession()获取session,如果session不存在则创建一个 94 HttpSession session = request.getSession(); 95 // 将数据存储到session中 96 session.setAttribute("ctitle", ctitle); 97 98 List<StorySituation> list = dao.gaojianqianfa_check(ctitle); 99 request.setAttribute("list", list); 100 request.getRequestDispatcher("ChiefEditor_gaojianqianfa_check.jsp").forward(request, response); 101 102 } 103 104 public void gaojianqianfa_checkResult(HttpServletRequest request, HttpServletResponse response) 105 throws ServletException, IOException { 106 response.setCharacterEncoding("UTF-8"); 107 request.setCharacterEncoding("UTF-8"); 108 109 String IsAgree = request.getParameter("IsAgree"); 110 111 // 使用request对象的getSession()获取session,如果session不存在则创建一个 112 HttpSession session = request.getSession(); 113 // 将数据取出 114 String ctitle = (String) session.getAttribute("ctitle"); 115 116 if (dao.gaojianqianfa_checkResult(ctitle, IsAgree)) { 117 request.getRequestDispatcher("ChiefServlet?method=ChiefEditor_gaojianqianfa").forward(request, response); 118 } else { 119 request.getRequestDispatcher("TestFail.jsp").forward(request, response); 120 } 121 122 } 123 124 public void ChiefEditor_chehuigaojian(HttpServletRequest request, HttpServletResponse response) 125 throws ServletException, IOException { 126 response.setCharacterEncoding("UTF-8"); 127 request.setCharacterEncoding("UTF-8"); 128 129 List<StorySituation> list = dao.chehuigaojian(); 130 request.setAttribute("list", list); 131 request.getRequestDispatcher("ChiefEditor_chehuigaojian.jsp").forward(request, response); 132 133 } 134 135 public void withdraw(HttpServletRequest request, HttpServletResponse response) 136 throws ServletException, IOException { 137 response.setCharacterEncoding("UTF-8"); 138 request.setCharacterEncoding("UTF-8"); 139 140 String ctitle = request.getParameter("ctitle"); 141 if (dao.withdraw(ctitle)) { 142 JOptionPane.showMessageDialog(null, "撤回成功", "success", JOptionPane.PLAIN_MESSAGE); 143 request.getRequestDispatcher("ChiefServlet?method=ChiefEditor_chehuigaojian").forward(request, response); 144 } else { 145 request.getRequestDispatcher("TestFail.jsp").forward(request, response); 146 } 147 148 } 149 150 public void chaxungaojian(HttpServletRequest request, HttpServletResponse response) 151 throws ServletException, IOException { 152 response.setCharacterEncoding("UTF-8"); 153 request.setCharacterEncoding("UTF-8"); 154 155 String ctitle = request.getParameter("ctitle"); 156 String ckey = request.getParameter("ckey"); 157 String cabstract = request.getParameter("cabstract"); 158 String name = request.getParameter("name"); 159 160 System.out.println(ctitle + "," + ckey + "," + cabstract + "," + name); 161 162 List<Story> list = dao.chaxungaojian(ctitle, ckey, cabstract, name); 163 request.setAttribute("list", list); 164 request.getRequestDispatcher("ChiefEditor_chaxungaojian.jsp").forward(request, response); 165 166 } 167 }
ChiefServletDao.java(在dao文件下建立此java文件)
1 package dao; 2 3 import java.sql.Connection; 4 import java.sql.PreparedStatement; 5 import java.sql.ResultSet; 6 import java.text.SimpleDateFormat; 7 import java.util.ArrayList; 8 import java.util.Date; 9 import java.util.List; 10 11 import databse.Database; 12 import util.Story; 13 import util.StorySituation; 14 15 public class ChiefDao { 16 /** 17 * 稿件签发 18 * @return 19 */ 20 public List<StorySituation> gaojianqianfa() { 21 List<StorySituation> list = new ArrayList<>(); 22 Connection conn = null; 23 ResultSet rs = null; 24 PreparedStatement pstm = null; 25 StorySituation storySituation = null; 26 try { 27 conn = Database.getConnection(); 28 String sql = "select * from storySituation where receiver=?"; 29 pstm = conn.prepareStatement(sql); 30 pstm.setString(1, "稿件评审已通过"); 31 rs = pstm.executeQuery(); 32 while (rs.next()) { 33 String ctitle = rs.getString("ctitle"); 34 String shenqianAgree = rs.getString("shenqianAgree"); 35 String shenqianOpinion = rs.getString("shenqianOpinion"); 36 String chachongResult = rs.getString("chachongResult"); 37 String name_one=rs.getString("name_one"); 38 String name_one_agree = rs.getString("name_one_agree"); 39 String name_one_opinion = rs.getString("name_one_opinion"); 40 String name_two=rs.getString("name_two"); 41 String name_two_agree = rs.getString("name_two_agree"); 42 String name_two_opinion = rs.getString("name_two_opinion"); 43 String name_three=rs.getString("name_three"); 44 String name_three_agree = rs.getString("name_three_agree"); 45 String name_three_opinion = rs.getString("name_three_opinion"); 46 storySituation = new StorySituation(ctitle, shenqianAgree, shenqianOpinion,chachongResult,name_one, name_one_agree,name_one_opinion, name_two, name_two_agree,name_two_opinion,name_three,name_three_agree,name_three_opinion); 47 list.add(storySituation); 48 } 49 } catch (Exception e) { 50 e.printStackTrace(); 51 } finally { 52 Database.close(conn, pstm, rs); 53 } 54 return list; 55 } 56 public List<StorySituation> gaojianqianfa_check(String ctitle) { 57 List<StorySituation> list = new ArrayList<>(); 58 Connection conn = null; 59 ResultSet rs = null; 60 PreparedStatement pstm = null; 61 StorySituation storySituation = null; 62 try { 63 conn = Database.getConnection(); 64 String sql = "select * from storySituation where ctitle=?"; 65 pstm = conn.prepareStatement(sql); 66 pstm.setString(1, ctitle); 67 rs = pstm.executeQuery(); 68 while (rs.next()) { 69 String ctitlee = rs.getString("ctitle"); 70 String shenqianAgree = rs.getString("shenqianAgree"); 71 String shenqianOpinion = rs.getString("shenqianOpinion"); 72 String chachongResult = rs.getString("chachongResult"); 73 String name_one=rs.getString("name_one"); 74 String name_one_agree = rs.getString("name_one_agree"); 75 String name_one_opinion = rs.getString("name_one_opinion"); 76 String name_two=rs.getString("name_two"); 77 String name_two_agree = rs.getString("name_two_agree"); 78 String name_two_opinion = rs.getString("name_two_opinion"); 79 String name_three=rs.getString("name_three"); 80 String name_three_agree = rs.getString("name_three_agree"); 81 String name_three_opinion = rs.getString("name_three_opinion"); 82 storySituation = new StorySituation(ctitlee, shenqianAgree, shenqianOpinion,chachongResult,name_one, name_one_agree,name_one_opinion, name_two, name_two_agree,name_two_opinion,name_three,name_three_agree,name_three_opinion); 83 list.add(storySituation); 84 } 85 } catch (Exception e) { 86 e.printStackTrace(); 87 } finally { 88 Database.close(conn, pstm, rs); 89 } 90 return list; 91 } 92 public boolean gaojianqianfa_checkResult(String ctitle,String IsAgree) { 93 Connection conn = null; 94 PreparedStatement pstm = null; 95 PreparedStatement pstm1 = null; 96 boolean judge = false; 97 String receiver="已签发"; 98 try { 99 if(IsAgree.equals("DisAgree")) { 100 receiver="退回稿件"; 101 } 102 conn = Database.getConnection(); 103 //稿件签发后,自动获取签发日期 104 SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式 105 System.out.println(df.format(new Date()));// new Date()为获取当前系统时间 106 String sql = "update story set receiver=?,time=? where ctitle=?"; 107 String sql1 = "update storysituation set receiver=? where ctitle=?"; 108 pstm = conn.prepareStatement(sql); 109 pstm.setString(1, receiver); 110 pstm.setString(2, df.format(new Date())); 111 pstm.setString(3, ctitle); 112 pstm1 = conn.prepareStatement(sql1); 113 pstm1.setString(1, receiver); 114 pstm1.setString(2, ctitle); 115 // 执行插入操作 116 int num = pstm.executeUpdate(); 117 int num1 = pstm1.executeUpdate(); 118 if (num > 0 & num1 > 0) { 119 System.out.println("签发成功"); 120 judge = true; 121 } else { 122 System.out.println("签发失败"); 123 judge = false; 124 } 125 } catch (Exception e) { 126 e.printStackTrace(); 127 } finally { 128 // SQL执行完成后释放相关资源 129 Database.close(conn, pstm); 130 } 131 return judge; 132 } 133 /** 134 * 撤回稿件 135 * @return 136 */ 137 public List<StorySituation> chehuigaojian() { 138 List<StorySituation> list = new ArrayList<>(); 139 Connection conn = null; 140 ResultSet rs = null; 141 PreparedStatement pstm = null; 142 StorySituation storySituation = null; 143 try { 144 conn = Database.getConnection(); 145 String sql = "select * from storySituation where receiver=?"; 146 pstm = conn.prepareStatement(sql); 147 pstm.setString(1, "已签发"); 148 rs = pstm.executeQuery(); 149 while (rs.next()) { 150 String ctitle = rs.getString("ctitle"); 151 String user_oppose_opinion = rs.getString("user_oppose_opinion"); 152 storySituation = new StorySituation(ctitle, user_oppose_opinion); 153 list.add(storySituation); 154 } 155 } catch (Exception e) { 156 e.printStackTrace(); 157 } finally { 158 Database.close(conn, pstm, rs); 159 } 160 return list; 161 } 162 public boolean withdraw(String ctitle) { 163 Connection conn = null; 164 PreparedStatement pstm = null; 165 PreparedStatement pstm1 = null; 166 boolean judge = false; 167 String receiver="稿件已退回"; 168 try { 169 conn = Database.getConnection(); 170 String sql = "update story set receiver=? where ctitle=?"; 171 String sql1 = "update storysituation set receiver=? where ctitle=?"; 172 pstm = conn.prepareStatement(sql); 173 pstm.setString(1, receiver); 174 pstm.setString(2, ctitle); 175 pstm1 = conn.prepareStatement(sql1); 176 pstm1.setString(1, receiver); 177 pstm1.setString(2, ctitle); 178 // 执行插入操作 179 int num = pstm.executeUpdate(); 180 int num1 = pstm1.executeUpdate(); 181 if (num > 0 & num1 > 0) { 182 System.out.println("退回成功"); 183 judge = true; 184 } else { 185 System.out.println("退回失败"); 186 judge = false; 187 } 188 } catch (Exception e) { 189 e.printStackTrace(); 190 } finally { 191 // SQL执行完成后释放相关资源 192 Database.close(conn, pstm); 193 } 194 return judge; 195 } 196 public List<Story> chaxungaojian(String ctitle,String ckey,String cabstract,String name) { 197 List<Story> list = new ArrayList<>(); 198 Connection conn = null; 199 ResultSet rs = null; 200 PreparedStatement pstm = null; 201 Story story = null; 202 try { 203 conn = Database.getConnection(); 204 205 if (ctitle.length() != 0 && ckey.equals("") && cabstract.equals("") && name.equals("")) { 206 // 通过中文标题查询 207 String sql = "select * from story where ctitle=?"; 208 pstm = conn.prepareStatement(sql); 209 pstm.setString(1, ctitle); 210 } else if (ctitle.equals("") && ckey.length() != 0 && cabstract.equals("") && name.equals("")) { 211 // 通过中文关键字查询 212 String sql = "select * from story where ckey=?"; 213 pstm = conn.prepareStatement(sql); 214 pstm.setString(1, ckey); 215 } else if (ctitle.equals("") && ckey.equals("") && cabstract.length() != 0 && name.equals("")) { 216 // 通过中文摘要查询 217 String sql = "select * from story where cabstract=?"; 218 pstm = conn.prepareStatement(sql); 219 pstm.setString(1, cabstract); 220 } else if (ctitle.equals("") && ckey.equals("") && cabstract.equals("") && name.length() != 0) { 221 // 通过作者名称查询 222 String sql = "select * from story where name=?"; 223 pstm = conn.prepareStatement(sql); 224 pstm.setString(1, name); 225 } else if (ctitle.equals("") && ckey.equals("") && cabstract.equals("") && name.equals("")) { 226 // 全查询 227 String sql = "select * from story"; 228 pstm = conn.prepareStatement(sql); 229 } else if (ctitle.length() != 0 && ckey.length() != 0 && cabstract.equals("") && name.equals("")) { 230 // 通过中文标题、中文关键字查询 231 String sql = "select * from story where ctitle=? and ckey=?"; 232 pstm = conn.prepareStatement(sql); 233 pstm.setString(1, ctitle); 234 pstm.setString(2, ckey); 235 } else if (ctitle.length() != 0 && ckey.equals("") && cabstract.length() != 0 && name.equals("")) { 236 // 通过中文标题、中文摘要查询 237 String sql = "select * from story where ctitle=? and cabstract=?"; 238 pstm = conn.prepareStatement(sql); 239 pstm.setString(1, ctitle); 240 pstm.setString(2, cabstract); 241 } else if (ctitle.length() != 0 && ckey.equals("") && cabstract.equals("") && name.length() != 0) { 242 // 通过中文标题、作者名称查询 243 String sql = "select * from story where ctitle=? and name=?"; 244 pstm = conn.prepareStatement(sql); 245 pstm.setString(1, ctitle); 246 pstm.setString(2, name); 247 } else if (ctitle.equals("") && ckey.length() != 0 && cabstract.length() != 0 && name.equals("")) { 248 // 通过中文关键字、中文摘要查询 249 String sql = "select * from story where ckey=? and cabstract=?"; 250 pstm = conn.prepareStatement(sql); 251 pstm.setString(1, ckey); 252 pstm.setString(2, cabstract); 253 } else if (ctitle.equals("") && ckey.length() != 0 && cabstract.equals("") && name.length() != 0) { 254 // 通过中文关键字、作者名称查询 255 String sql = "select * from story where ckey=? and name=?"; 256 pstm = conn.prepareStatement(sql); 257 pstm.setString(1, ckey); 258 pstm.setString(2, name); 259 } else if (ctitle.equals("") && ckey.equals("") && cabstract.length() != 0 && name.length() != 0) { 260 // 通过中文摘要、作者名称查询 261 String sql = "select * from story where cabstract=? and name=?"; 262 pstm = conn.prepareStatement(sql); 263 pstm.setString(1, cabstract); 264 pstm.setString(2, name); 265 } else if (ctitle.length() != 0 && ckey.length() != 0 && cabstract.length() != 0 && name.equals("")) { 266 // 通过中文标题、中文关键字、中文摘要查询 267 String sql = "select * from story where ctitle=? and ckey=? and cabstract=?"; 268 pstm = conn.prepareStatement(sql); 269 pstm.setString(1, ctitle); 270 pstm.setString(2, ckey); 271 pstm.setString(3, cabstract); 272 } else if (ctitle.length() != 0 && ckey.length() != 0 && cabstract.equals("") && name.length() != 0) { 273 // 通过中文标题、中文关键字、作者名称查询 274 String sql = "select * from story where ctitle=? and ckey=? and name=?"; 275 pstm = conn.prepareStatement(sql); 276 pstm.setString(1, ctitle); 277 pstm.setString(2, ckey); 278 pstm.setString(3, name); 279 } else if (ctitle.length() != 0 && ckey.equals("") && cabstract.length() != 0 && name.length() != 0) { 280 // 通过中文标题、中文摘要、作者名称查询 281 String sql = "select * from story where ctitle=? and cabstract=? and name=?"; 282 pstm = conn.prepareStatement(sql); 283 pstm.setString(1, ctitle); 284 pstm.setString(2, cabstract); 285 pstm.setString(3, name); 286 } else if (ctitle.equals("") && ckey.length() != 0 && cabstract.length() != 0 && name.length() != 0) { 287 // 通过中文关键字、中文摘要、作者名称查询 288 String sql = "select * from story where ckey=? and cabstract=? and name=?"; 289 pstm = conn.prepareStatement(sql); 290 pstm.setString(1, ckey); 291 pstm.setString(2, cabstract); 292 pstm.setString(3, name); 293 } else { 294 // 通过中文标题、中文关键字、中文摘要、作者名称查询 295 String sql = "select * from story where ctitle=? and ckey=? and cabstract=? and name=?"; 296 pstm = conn.prepareStatement(sql); 297 pstm.setString(1, ctitle); 298 pstm.setString(2, ckey); 299 pstm.setString(3, cabstract); 300 pstm.setString(4, name); 301 } 302 303 rs = pstm.executeQuery(); 304 while (rs.next()) { 305 String ctitlee = rs.getString("ctitle"); 306 String etitle = rs.getString("etitle"); 307 String cabstractt = rs.getString("cabstract"); 308 String eabstract = rs.getString("eabstract"); 309 String ckeyy = rs.getString("ckey"); 310 String ekey = rs.getString("ekey"); 311 String content = rs.getString("content"); 312 String receiver = rs.getString("receiver"); 313 String status = rs.getString("status"); 314 String namee = rs.getString("name"); 315 story = new Story(ctitlee, etitle, cabstractt, eabstract, ckeyy, ekey, content, receiver, status, namee); 316 list.add(story); 317 } 318 319 } catch (Exception e) { 320 e.printStackTrace(); 321 } finally { 322 Database.close(conn, pstm, rs); 323 } 324 return list; 325 } 326 }