一、'格式审查'功能
二、效果如下
三、代码如下
Proofread.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 href="ProofreadServlet?method=geshishencha" target="frame">格式审查</a></li> 44 <li class="layui-nav-item"><a href="ProofreadServlet?method=neirongchachong" 45 target="frame">内容查重</a></li> 46 <li class="layui-nav-item"><a href="ProofreadServlet?method=shengaoliucheng" 47 target="frame">审稿流程</a></li> 48 </ul> 49 </div> 50 </div> 51 <div class="layui-body"> 52 <!-- 内容主体区域 --> 53 <iframe name="frame" width="100%" height="100%" 54 style="border: 1px solid #CCC;"></iframe> 55 </div> 56 <div> 57 <div> 58 <input type="text" id="date" /> 59 </div> 60 </div> 61 </div> 62 63 </body> 64 </html>
Proofread_geshishencha.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 <colgroup> 16 <col width="150"> 17 <col width="200"> 18 <col> 19 </colgroup> 20 <thead> 21 <tr> 22 <th>id</th> 23 <th>中文标题</th> 24 <th>英文标题</th> 25 <th>投稿人</th> 26 <th>操作</th> 27 </tr> 28 </thead> 29 <tbody> 30 <c:forEach items="${list}" var="story" varStatus="status"> 31 <tr> 32 <td>${ status.index + 1}</td> 33 <td>${story.ctitle}</td> 34 <td>${story.etitle}</td> 35 <td>${story.name}</td> 36 <td><button class="layui-btn layui-btn-normal" 37 onclick="window.location.href='ProofreadServlet?method=check&ctitle=${story.ctitle}'">审查</button></td> 38 </tr> 39 </c:forEach> 40 </tbody> 41 </table> 42 </body> 43 </html>
Proofread_geshishencha_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 <form class="layui-form" action="ProofreadServlet?method=checkResult" 15 method="post"> 16 <c:forEach items="${list}" var="story"> 17 <div class="layui-form-item"> 18 <label class="layui-form-label">中文标题</label> 19 <div class="layui-input-block"> 20 <input type="text" name="ctitle" required lay-verify="required" 21 placeholder="请输入中文标题" autocomplete="off" class="layui-input" 22 value="${story.ctitle}"> <input type="text" 23 name="judgectitle" required lay-verify="required" 24 placeholder="请输入中文标题" autocomplete="off" class="layui-input" 25 value="${story.ctitle}"> 26 </div> 27 <div class="layui-form-mid layui-word-aux">(限100字以内)</div> 28 </div> 29 <div class="layui-form-item layui-form-text"> 30 <label class="layui-form-label">英文标题</label> 31 <div class="layui-input-block"> 32 <input type="text" name="etitle" required lay-verify="required" 33 placeholder="请输入英文标题" autocomplete="off" class="layui-input" 34 value="${story.etitle}"> 35 </div> 36 <div class="layui-form-mid layui-word-aux">(限400个字符以内)</div> 37 </div> 38 <div class="layui-form-item"> 39 <label class="layui-form-label">中文摘要</label> 40 <div class="layui-inline"> 41 <input type="text" name="cabstract" required lay-verify="required" 42 placeholder="请输入中文摘要" autocomplete="off" class="layui-input" 43 value="${story.cabstract}"> 44 </div> 45 <div class="layui-form-mid layui-word-aux">(限300字以内)</div> 46 </div> 47 <div class="layui-form-item"> 48 <label class="layui-form-label">英文摘要</label> 49 <div class="layui-inline"> 50 <input type="text" name="eabstract" required lay-verify="required" 51 placeholder="请输入英文摘要" autocomplete="off" class="layui-input" 52 value="${story.eabstract}"> 53 </div> 54 <div class="layui-form-mid layui-word-aux">(限3000字符以内)</div> 55 </div> 56 <div class="layui-form-item"> 57 <label class="layui-form-label">中文关键字</label> 58 <div class="layui-inline"> 59 <input type="text" name="ckey" required lay-verify="required" 60 placeholder="请输入中文关键字" autocomplete="off" class="layui-input" 61 value="${story.ckey}"> 62 </div> 63 <div class="layui-form-mid layui-word-aux">(限100字以内)</div> 64 </div> 65 <div class="layui-form-item"> 66 <label class="layui-form-label">英文关键字</label> 67 <div class="layui-inline"> 68 <input type="text" name="ekey" required lay-verify="required" 69 placeholder="请输入英文关键字" autocomplete="off" class="layui-input" 70 value="${story.ekey}"> 71 </div> 72 <div class="layui-form-mid layui-word-aux">(限200个字符以内)</div> 73 </div> 74 <div class="layui-form-item layui-form-text"> 75 <label class="layui-form-label">稿件正文</label> 76 <div class="layui-input-block"> 77 <textarea name="content" placeholder="请输入稿件正文" 78 class="layui-textarea">${story.content}</textarea> 79 </div> 80 </div> 81 <div class="layui-form-item"> 82 <label class="layui-form-label">投稿人</label> 83 <div class="layui-input-block"> 84 <input type="text" name="name" required lay-verify="required" 85 placeholder="请输入您的账号" autocomplete="off" class="layui-input" 86 value="${story.name}"> 87 </div> 88 </div> 89 <div class="layui-form-item"> 90 <label class="layui-form-label">是否同意</label> 91 <div class="layui-input-block"> 92 <input type="radio" name="shenqianAgree" value="同意" title="同意" 93 checked> <input type="radio" name="shenqianAgree" 94 value="不同意" title="不同意"> 95 </div> 96 </div> 97 <div class="layui-form-item layui-form-text"> 98 <label class="layui-form-label">意见</label> 99 <div class="layui-input-block"> 100 <textarea name="shenqianOpinion" placeholder="请输入您的意见" 101 class="layui-textarea"></textarea> 102 </div> 103 </div> 104 <div class="layui-form-item"> 105 <div class="layui-input-block"> 106 <button class="layui-btn" lay-submit>修改</button> 107 <button type="reset" class="layui-btn layui-btn-primary">重置</button> 108 </div> 109 </div> 110 </c:forEach> 111 </form> 112 </body> 113 </html>
ProofreadServlet.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.ProofreadDao; 15 import util.Story; 16 17 18 /** 19 * Servlet implementation class ProofreadServlet 20 */ 21 @WebServlet("/ProofreadServlet") 22 public class ProofreadServlet extends HttpServlet { 23 private static final long serialVersionUID = 1L; 24 25 /** 26 * @see HttpServlet#HttpServlet() 27 */ 28 public ProofreadServlet() { 29 super(); 30 // TODO Auto-generated constructor stub 31 } 32 33 ProofreadDao dao = new ProofreadDao(); 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 request.setCharacterEncoding("utf-8"); 55 response.setCharacterEncoding("utf-8"); 56 57 System.out.println("进入ContributeServlet"); 58 String method = request.getParameter("method"); 59 System.out.println(method); 60 if ("geshishencha".equals(method)) { 61 geshishencha(request, response);// 格式审查 62 } else if ("check".equals(method)) { 63 check(request, response);// 审查 64 } else if ("checkResult".equals(method)) { 65 checkResult(request, response); 66 } 67 } 68 69 public void geshishencha(HttpServletRequest request, HttpServletResponse response) 70 throws ServletException, IOException { 71 response.setCharacterEncoding("UTF-8"); 72 request.setCharacterEncoding("UTF-8"); 73 74 System.out.println("进入geshishencha"); 75 List<Story> list = dao.geshishencha(); 76 request.setAttribute("list", list); 77 request.getRequestDispatcher("Proofread_geshishencha.jsp").forward(request, response); 78 79 } 80 81 public void check(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 82 response.setCharacterEncoding("UTF-8"); 83 request.setCharacterEncoding("UTF-8"); 84 85 String ctitle = request.getParameter("ctitle"); 86 List<Story> list = dao.check(ctitle); 87 request.setAttribute("list", list); 88 request.getRequestDispatcher("Proofread_geshishencha_check.jsp").forward(request, response); 89 90 } 91 92 public void checkResult(HttpServletRequest request, HttpServletResponse response) 93 throws ServletException, IOException { 94 response.setCharacterEncoding("UTF-8"); 95 request.setCharacterEncoding("UTF-8"); 96 97 String ctitle = request.getParameter("judgectitle"); 98 String shenqianAgree = request.getParameter("shenqianAgree"); 99 String shenqianOpinion = request.getParameter("shenqianOpinion"); 100 101 if (dao.checkResult(ctitle, shenqianAgree, shenqianOpinion)) { 102 JOptionPane.showMessageDialog(null, "审查成功", "success", JOptionPane.PLAIN_MESSAGE); 103 request.getRequestDispatcher("ProofreadServlet?method=geshishencha").forward(request, response); 104 } else { 105 request.getRequestDispatcher("TestFail.jsp").forward(request, response); 106 } 107 108 } 109 110 }
ProofreadDao.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.util.ArrayList; 7 import java.util.List; 8 9 import databse.Database; 10 import util.Story; 11 12 public class ProofreadDao { 13 /** 14 * 格式审查 15 * @return 16 */ 17 public List<Story> geshishencha() { 18 List<Story> list = new ArrayList<>(); 19 Connection conn = null; 20 ResultSet rs = null; 21 PreparedStatement pstm = null; 22 Story story = null; 23 try { 24 conn = Database.getConnection(); 25 String sql = "select * from story where receiver=?"; 26 pstm = conn.prepareStatement(sql); 27 pstm.setString(1, "格式审查中"); 28 rs = pstm.executeQuery(); 29 while (rs.next()) { 30 String ctitle = rs.getString("ctitle"); 31 String etitle = rs.getString("etitle"); 32 String cabstract = rs.getString("cabstract"); 33 String eabstract = rs.getString("eabstract"); 34 String ckey = rs.getString("ckey"); 35 String ekey = rs.getString("ekey"); 36 String content = rs.getString("content"); 37 String receiver = rs.getString("receiver"); 38 String status = rs.getString("status"); 39 String name = rs.getString("name"); 40 story = new Story(ctitle, etitle, cabstract, eabstract, ckey, ekey, content, receiver, status, name); 41 list.add(story); 42 } 43 } catch (Exception e) { 44 e.printStackTrace(); 45 } finally { 46 Database.close(conn, pstm, rs); 47 } 48 return list; 49 } 50 public List<Story> check(String ctitle) { 51 List<Story> list = new ArrayList<>(); 52 Connection conn = null; 53 ResultSet rs = null; 54 PreparedStatement pstm = null; 55 Story story = null; 56 try { 57 conn = Database.getConnection(); 58 String sql = "select * from story where ctitle=?"; 59 pstm = conn.prepareStatement(sql); 60 pstm.setString(1, ctitle); 61 rs = pstm.executeQuery(); 62 while (rs.next()) { 63 String ctitlee = rs.getString("ctitle"); 64 String etitle = rs.getString("etitle"); 65 String cabstract = rs.getString("cabstract"); 66 String eabstract = rs.getString("eabstract"); 67 String ckey = rs.getString("ckey"); 68 String ekey = rs.getString("ekey"); 69 String content = rs.getString("content"); 70 String receiver = rs.getString("receiver"); 71 String status = rs.getString("status"); 72 String name = rs.getString("name"); 73 story = new Story(ctitlee, etitle, cabstract, eabstract, ckey, ekey, content, receiver, status, name); 74 list.add(story); 75 } 76 } catch (Exception e) { 77 e.printStackTrace(); 78 } finally { 79 Database.close(conn, pstm, rs); 80 } 81 return list; 82 } 83 84 public boolean checkResult(String ctitle, String shenqianAgree, String shenqianOpinion) { 85 Connection conn = null; 86 PreparedStatement pstm = null; 87 PreparedStatement pstm1 = null; 88 boolean judge = false; 89 String receiver; 90 try { 91 if(shenqianAgree.equals("同意")) { 92 receiver = "审签同意"; 93 }else { 94 receiver = "审签不同意"; 95 } 96 conn = Database.getConnection(); 97 String sql = "update story set receiver=? where ctitle=?"; 98 String sql1 = "update storysituation set shenqianAgree=?,shenqianOpinion=?,receiver=? where ctitle=?"; 99 pstm = conn.prepareStatement(sql); 100 pstm.setString(1, receiver); 101 pstm.setString(2, ctitle); 102 pstm1 = conn.prepareStatement(sql1); 103 pstm1.setString(1, shenqianAgree); 104 pstm1.setString(2, shenqianOpinion); 105 pstm1.setString(3, receiver); 106 pstm1.setString(4, ctitle); 107 // 执行插入操作 108 int num = pstm.executeUpdate(); 109 int num1 = pstm1.executeUpdate(); 110 if (num > 0 & num1 > 0) { 111 System.out.println("审签成功"); 112 judge = true; 113 } else { 114 System.out.println("审签失败"); 115 judge = false; 116 } 117 } catch (Exception e) { 118 e.printStackTrace(); 119 } finally { 120 // SQL执行完成后释放相关资源 121 Database.close(conn, pstm); 122 } 123 return judge; 124 } 125 126 }