Java期末考试冲刺总结
经过长达将近三个小时的冲刺,我感觉身心俱疲,但它无法掩盖我敲代码的欲望!
三个小时我只实现了公文流转系统的的部分功能。
我深刻的意识到建民老师说的这套关系之复杂,它真的是太复杂了!!!没有系统的梳理,之前也没有系统地敲过这样一个程序,敲起来感到十分的头大!
期末考试感觉压力很大!
这部分是部门写邮件的代码,这部分我卡的是转码的问题,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);
} }
目前只写出了这么点,稍后会完善并进行深度总结!
Java期末考试冲刺总结的更多相关文章
- java 期末考试复习
//Scanner这样写? Scanner input = new Scanner(System.in); //不断获得下一个单词 names[i] = toTitleCase(input.nex ...
- java期末考试
水仙花数 package txt; public class shuixianhua { public static void main(String[] args) { // TODO Auto-g ...
- Java期末考试编程题复习
在程序中定义Person类,为该类编写如下字段.构造器.访问器.修改器和相应的其他方法.(20分) <1>在Person类中定义两个字段: 私有访问权限,类型为String的name字段: ...
- Java 期末考试
一: 题目:打印出100-999之间所有的"水仙花数",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该数本身. 例如:153是一个"水仙花 ...
- JAVA期末考试整理
Technical problem: 0.read: Scanner input= new Scanner(System.in) random#: x=(int)(Math.random()*10) ...
- Java开发工程师(Web方向) - 03.数据库开发 - 期末考试
期末考试 编程题 本编程题包含4个小题,覆盖知识点从基础的JDBC.连接池到MyBatis. 1(10分) 有一款在线教育产品“天天向上”主要实现了在手机上查看课程表的功能.该产品的后端系统有一张保存 ...
- 中国MOOC_面向对象程序设计——Java语言_期末考试编程题_1细胞自动机
期末考试编程题 返回 这是期末考试的编程题 温馨提示: 1.本次考试属于Online Judge题目,提交后由系统即时判分. 2.学生可以在考试截止时间之前提交答案,系统将取其中的最高分作为最终成 ...
- 中国MOOC_零基础学Java语言_期末考试的编程题_1二进制的前导的零
期末考试的编程题 返回 这是期末考试的编程题,在60分钟内,你可以多次提交,直到正确为止. 温馨提示: 1.本次考试属于Online Judge题目,提交后由系统即时判分. 2.学生可以在考试截止 ...
- 复旦大学2015--2016学年第二学期高等代数II期末考试情况分析
一.期末考试成绩班级前几名 胡晓波(90).杨彦婷(88).宋卓卿(85).唐指朝(84).陈建兵(83).宋沛颖(82).王昊越(81).白睿(80).韩沅伯(80).王艺楷(80).张漠林(80) ...
随机推荐
- IO流(字节流,字符流)
一,概述 IO流(input output):用来处理设备之间的数据. Java对数据的操作是通过流的对象. Java用于操作流的对象都在IO包中. 流是一组有顺序的,有起点和终点的字节集合,是对数据 ...
- OpenCV3入门(十)图像轮廓
1.图像轮廓 1.1图像轮廓与API函数 轮廓是一系列相连的点组成的曲线,代表了物体的基本外形,相对于边缘,轮廓是连续的,边缘并不全部连续.一般地,获取图像轮廓要经过下面几个步骤: 1) 读取 ...
- 回到未来:Smalltalk 编程系统
Smalltalk 是19世纪70年代由 Alan Kay 设计的,第一个以面向对象(Object-Orientation)为主要范式的编程语言 1.Smalltalk 具有大量首创的特性,深刻影响了 ...
- Happycorp:1 Vulnhub Walkthrough
靶机链接: https://www.vulnhub.com/entry/happycorp-1,296/ 网络主机扫描::: 主机端口扫描: NFS文件系统,尝试挂载试试 mount -t nfs 1 ...
- [MySQL]mysql binlog回滚数据
1.先开启binlog log-bin = /var/log/mysql/mysql_bin #binlog日志文件,以mysql_bin开头,六个数字结尾的文件:mysql_bin.000001,并 ...
- 【HDU - 1029】Ignatius and the Princess IV (水题)
Ignatius and the Princess IV 先搬中文 Descriptions: 给你n个数字,你需要找出出现至少(n+1)/2次的数字 现在需要你找出这个数字是多少? Input ...
- 传智播客C++视频学习笔记(1)
下载Visual Studio Community版本, #include<iostream> using namespace std; int main() { cout << ...
- 使用ffmpeg为影片添加字幕
ffmpeg -i infile.mp4 -i infile.srt -c copy -c:s mov_text outfile.mp4 The order of -c copy -c:s mov_t ...
- vue中报错Do not use built-in or reserved HTML elements as component id details
原因是定义了一个叫做details的comonent 跟现有的html网页中的标签重合 export default { name: 'details', data () { return { equ ...
- vim编辑超大文件
进入大文件(12g,250w+ lines),vim,耐心等待 有两种方法编辑删除冗余字段 1.set number ,可以通过:+数字组合跳到指定行,输入命令 ":100,200d&q ...