经过长达将近三个小时的冲刺,我感觉身心俱疲,但它无法掩盖我敲代码的欲望!
三个小时我只实现了公文流转系统的的部分功能。
我深刻的意识到建民老师说的这套关系之复杂,它真的是太复杂了!!!没有系统的梳理,之前也没有系统地敲过这样一个程序,敲起来感到十分的头大!
期末考试感觉压力很大!
这部分是部门写邮件的代码,这部分我卡的是转码的问题,url传值出现了问题,最新版本的tomcat并不支持其他字符,需要转码
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
#d1{
text-align: center;
padding-top: 40px;
font-family: "微软雅黑";
font-size: 40px;
background-color: #DDDDDD;
height: 100px;
}
div ul{
vertical-align: top;
list-style-type: none;
margin: 0px;
vertical-align: left;
width: 200px;
padding: 0px;
border-top: 20px solid #F8A0E7;
border-bottom :20px solid #F8A0E7;
}
.headd{
font-family: "微软雅黑";
lighting-color: red;
font-size: 20px;
}
div li a{
height: 80px;
display: block;
padding: 0px 0px 0px 0em;
text-decoration: none;
border-left: 20px solid pink;
}
div li a:link,div li a:visited{
background-color: #F0F0F0;
color: #461737;
}
div li a:hover{
background-color: green;
color: gray;
}
div li a:active{
background-color: pink;
}
#left{
float:left;
}
#right{
height:400px;
width:120px;
float:left;
border:1px solid green;
}
#inp{
float:left;
height:400px;
width:1202px;
}
.btn{
float:left;
}
</style>
<script type="text/javascript">
//function Onload(){
// var s="<%=request.getParameter("message")%>";
// if (s !== null || s !== undefined ||s !== '') {
// alert(s);
// }
//}
function Out(){
var title=document.getElementById("title").value;
if(title=="") {
alert("标题不能为空!!!");
return false;
}
var text=encodeURIComponent(document.getElementById("inp").value);
var s="SaveAritical?text="+text+"&type=Document&title="+encodeURIComponent(title);
window.location.href=s;
}
function Save(){
var title=document.getElementById("title").value;
if(title=="") {
alert("标题不能为空!!!");
return false;
}
var text=encodeURIComponent(document.getElementById("inp").value);
var s="OutAritical?text="+text+"&type=Document&title="+encodeURIComponent(title);
window.location.href=s;
} </script>
</head>
<body onload="Onload()">
<div id="d1">Aritical Of Department</div>
<div id="left">
<ul>
<li class="headd"><a href="#" onclick="fresh()">Refresh</a></li>
<li><a href="Document.jsp">公文拟制</a></li>
<li><a href="Receive?type=Document">签收公文</a></li>
<li><a href="DocumentView.jsp">浏览公文</a></li>
</ul>
</div>
<div id="right">
<div><textarea type="text" id="title" placeholder="输入标题"> </textarea></div>
<div ><textarea type="text" id="inp" placeholder="输入内容"> </textarea></div>
<div><button class="btn" onclick="Save()">保存</button></div>
<div><button class="btn" onclick="Out()">发布</button></div> </div>
</body>
</html>
这部分是保存 html:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
#d1{
text-align: center;
padding-top: 40px;
font-family: "微软雅黑";
font-size: 40px;
background-color: #DDDDDD;
height: 100px;
}
div ul{
vertical-align: top;
list-style-type: none;
margin: 0px;
vertical-align: left;
width: 200px;
padding: 0px;
border-top: 20px solid #F8A0E7;
border-bottom :20px solid #F8A0E7;
}
.headd{
font-family: "微软雅黑";
lighting-color: red;
font-size: 20px;
}
div li a{
height: 80px;
display: block;
padding: 0px 0px 0px 0em;
text-decoration: none;
border-left: 20px solid pink;
}
div li a:link,div li a:visited{
background-color: #F0F0F0;
color: #461737;
}
div li a:hover{
background-color: green;
color: gray;
}
div li a:active{
background-color: pink;
}
#left{
float:left;
}
#right{
height:400px;
width:120px;
float:left;
border:1px solid green;
}
#inp{
float:left;
height:400px;
width:1202px;
}
.btn{
float:left;
}
</style>
<script type="text/javascript">
function Onload(){
alert("发布成功!");
}
function Out(){
var title=document.getElementById("title").value;
if(title=="") {
alert("标题不能为空!!!");
return false;
}
var text=encodeURIComponent(document.getElementById("inp").value);
var s="OutAritical?text="+text+"&type=Document&title="+title;
window.location.href=s;
}
function Save(){
var title=document.getElementById("title").value;
if(title=="") {
alert("标题不能为空!!!");
return false;
}
var text=encodeURIComponent(document.getElementById("inp").value);
var s="SaveAritical?text="+text+"&type=Document&title="+title;
window.location.href=s;
} </script>
</head>
<body onload="Onload()">
<div id="d1">Aritical Of Department</div>
<div id="left">
<ul>
<li class="headd"><a href="#" onclick="fresh()">Refresh</a></li>
<li><a href="Produce.jsp">公文拟制</a></li>
<li><a href="Receive.jsp">签收公文</a></li>
<li><a href="View.jsp">浏览公文</a></li>
</ul>
</div>
<div id="right">
<div><textarea type="text" id="title" placeholder="输入标题"> </textarea></div>
<div ><textarea type="text" id="inp" placeholder="输入内容"> </textarea></div>
<div><button class="btn" onclick="Save()">保存</button></div>
<div><button class="btn" onclick="Out()">发布</button></div> </div>
</body>
</html>
servlet:
package com.Aritical.servlet; import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement; import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/SaveAritical")
public class SaveAritical extends HttpServlet {
private static final long serialVersionUID = 1L;
public SaveAritical() {
super();
// TODO Auto-generated constructor stub
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String text=request.getParameter("text");
String type=request.getParameter("type");
String title=request.getParameter("title");
Link l=new Link();
try {
int id=0;
Connection con=l.lin("AriticalManager");
Statement stmt=con.createStatement();
String queryid="select * from Aritical_"+type;
ResultSet rsst=stmt.executeQuery(queryid);
while(rsst.next()) {
id=Integer.parseInt(rsst.getString("id"));
}
rsst.close();
id++;
String s="insert into Aritical values("+id+",1,'"+title+"','"+text+"')";
stmt.executeUpdate(s);
stmt.close();
con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String url=type+"Out.jsp";
request.getRequestDispatcher(url).forward(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
} }
这是servlet:
package com.Aritical.servlet; import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement; import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/OutAritical")
public class OutAritical extends HttpServlet {
private static final long serialVersionUID = 1L;
public OutAritical() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String text=request.getParameter("text");
String type=request.getParameter("type");
String title=request.getParameter("title");
Link l=new Link();
try {
int id=0;
Connection con=l.lin("AriticalManager");
Statement stmt=con.createStatement();
String queryid="select * from Aritical_"+type;
ResultSet rsst=stmt.executeQuery(queryid);
while(rsst.next()) {
id=Integer.parseInt(rsst.getString("id"));
}
rsst.close();
id++;
String s="insert into Aritical_"+type+" values("+id+",0,'"+title+"','"+text+"')";
stmt.executeUpdate(s);
stmt.close();
con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String url=type+"Save.jsp";
request.getRequestDispatcher(url).forward(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
} }
这部分是发布的代码
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
#d1{
text-align: center;
padding-top: 40px;
font-family: "微软雅黑";
font-size: 40px;
background-color: #DDDDDD;
height: 100px;
}
div ul{
vertical-align: top;
list-style-type: none;
margin: 0px;
vertical-align: left;
width: 200px;
padding: 0px;
border-top: 20px solid #F8A0E7;
border-bottom :20px solid #F8A0E7;
}
.headd{
font-family: "微软雅黑";
lighting-color: red;
font-size: 20px;
}
div li a{
height: 80px;
display: block;
padding: 0px 0px 0px 0em;
text-decoration: none;
border-left: 20px solid pink;
}
div li a:link,div li a:visited{
background-color: #F0F0F0;
color: #461737;
}
div li a:hover{
background-color: green;
color: gray;
}
div li a:active{
background-color: pink;
}
#left{
float:left;
}
#right{
height:400px;
width:120px;
float:left;
border:1px solid green;
}
#inp{
float:left;
height:400px;
width:1202px;
}
.btn{
float:left;
}
</style>
<script type="text/javascript">
function Onload(){
alert("发布成功!");
}
function Out(){
var title=document.getElementById("title").value;
if(title=="") {
alert("标题不能为空!!!");
return false;
}
var text=encodeURIComponent(document.getElementById("inp").value);
var s="OutAritical?text="+text+"&type=Document&title="+title;
window.location.href=s;
}
function Save(){
var title=document.getElementById("title").value;
if(title=="") {
alert("标题不能为空!!!");
return false;
}
var text=encodeURIComponent(document.getElementById("inp").value);
var s="SaveAritical?text="+text+"&type=Document&title="+title;
window.location.href=s;
} </script>
</head>
<body onload="Onload()">
<div id="d1">Aritical Of Department</div>
<div id="left">
<ul>
<li class="headd"><a href="#" onclick="fresh()">Refresh</a></li>
<li><a href="Produce.jsp">公文拟制</a></li>
<li><a href="Receive.jsp">签收公文</a></li>
<li><a href="View.jsp">浏览公文</a></li>
</ul>
</div>
<div id="right">
<div><textarea type="text" id="title" placeholder="输入标题"> </textarea></div>
<div ><textarea type="text" id="inp" placeholder="输入内容"> </textarea></div>
<div><button class="btn" onclick="Save()">保存</button></div>
<div><button class="btn" onclick="Out()">发布</button></div> </div>
</body>
</html>
这是发布的servlet:
package com.Aritical.servlet; import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement; import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/SaveAritical")
public class SaveAritical extends HttpServlet {
private static final long serialVersionUID = 1L;
public SaveAritical() {
super();
// TODO Auto-generated constructor stub
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String text=request.getParameter("text");
String type=request.getParameter("type");
String title=request.getParameter("title");
Link l=new Link();
try {
int id=0;
Connection con=l.lin("AriticalManager");
Statement stmt=con.createStatement();
String queryid="select * from Aritical_"+type;
ResultSet rsst=stmt.executeQuery(queryid);
while(rsst.next()) {
id=Integer.parseInt(rsst.getString("id"));
}
rsst.close();
id++;
String s="insert into Aritical values("+id+",1,'"+title+"','"+text+"')";
stmt.executeUpdate(s);
stmt.close();
con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String url=type+"Out.jsp";
request.getRequestDispatcher(url).forward(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
} }
签收:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>DocumentReceive</title>
<style type="text/css">
#d1{
text-align: center;
padding-top: 40px;
font-family: "微软雅黑";
font-size: 40px;
background-color: #DDDDDD;
height: 100px;
}
div ul{
vertical-align: top;
list-style-type: none;
margin: 0px;
vertical-align: left;
width: 200px;
padding: 0px;
border-top: 20px solid #F8A0E7;
border-bottom :20px solid #F8A0E7;
}
.headd{
font-family: "微软雅黑";
lighting-color: red;
font-size: 20px;
}
div li a{
height: 80px;
display: block;
padding: 0px 0px 0px 0em;
text-decoration: none;
border-left: 20px solid pink;
}
div li a:link,div li a:visited{
background-color: #F0F0F0;
color: #461737;
}
div li a:hover{
background-color: green;
color: gray;
}
div li a:active{
background-color: pink;
}
#left{
float:left;
}
#right{
height:400px;
width:120px;
float:left;
border:1px solid green;
}
#inp{
float:left;
height:400px;
width:1202px;
}
.btn{
float:left;
}
</style>
<script type="text/javascript">
function receive(){ }
</script>
</head>
<body>
<div id="d1">Aritical Of Department</div>
<div id="left">
<ul>
<li class="headd"><a href="#" onclick="fresh()">Refresh</a></li>
<li><a href="Document.jsp">公文拟制</a></li>
<li><a href="Receive?type=Document">签收公文</a></li>
<li><a href="DocumentView.jsp">浏览公文</a></li>
</ul>
</div>
<div id="right">
<table>
<c:forEach items="${list}" var="list" >
<tr>
<td onmouseover="this.style.backgroundColor='#FCADEC';"
onmouseout="this.style.backgroundColor='#d4e3e5';">${list.id}</td>
<td onmouseover="this.style.backgroundColor='#FCADEC';"
onmouseout="this.style.backgroundColor='#d4e3e5';">${list.state}</td>
<td onmouseover="this.style.backgroundColor='#FCADEC';"
onmouseout="this.style.backgroundColor='#d4e3e5';">${list.title}</td>
</tr>
<button onclick="receive()">签收</button>
</c:forEach>
</table>
</div>
</body>
</html>
这部分还没完善servlet:
package com.Aritical.servlet; import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList; import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; /**
* Servlet implementation class Receive
*/
@WebServlet("/Receive")
public class Receive extends HttpServlet {
private static final long serialVersionUID = 1L;
public Receive() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String type=request.getParameter("type");
int min=0,max=0;
ArrayList<AriticalBean> arr=new ArrayList<AriticalBean>();
switch (type) {
case "Document":
{ min=1;
max=4;
break;
}
default:
break;
}
Link l=new Link();
try {
Connection con=l.lin("AriticalManager");
Statement stmt=con.createStatement();
String s="select * from Aritical where id between "+min+" and "+max;
ResultSet rsst=stmt.executeQuery(s);
while(rsst.next()) {
AriticalBean ab=new AriticalBean();
ab.setId(rsst.getInt("id"));
ab.setState(rsst.getInt("state"));
ab.setTitle(rsst.getString("title"));
ab.setText(rsst.getString("text"));
arr.add(ab);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
request.setAttribute("list", arr);
String s=type+"Receive.jsp";
request.getRequestDispatcher(s).forward(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
} }
目前只写出了这么点,稍后会完善并进行深度总结!