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) ...
随机推荐
- Python学习小记(1)---import小记
在这种目录结构下,import fibo会实际导入fibo文件夹这个module λ tree /F 卷 Programs 的文件夹 PATH 列表 卷序列号为 BC56-3256 D:. │ fib ...
- js能力测评——移除数组中的元素
移除数组中的元素 题目描述 : 移除数组 arr 中的所有值与 item 相等的元素.不要直接修改数组 arr,结果返回新的数组 示例1 输入 [1, 2, 3, 4, 2], 2 输出 [1, 3, ...
- Django3的安装以及web项目的创建
cmd 直接输入:pip install -i https://pypi.douban.com/simple django 2.检测是否安装成功:用到的命令:import django ,检测版本 ...
- Gartner评估:众包将掀起IT服务市场的革命
国际IT顾问与咨询公司Gartner发布评估报告,称众包是中国的一种新兴业务模式,将掀起IT服务市场的革命.然而,只有很少的的服务提供商会构建众包平台来尝试使用该业务模式.IT服务提供商的业务部门负责 ...
- 《自拍教程22》wget_文件下载工具
wget用途介绍 日常测试过程中,我们可以用wget命令,来下载一些资源文件. wget是一个很好文件下载命令, Linux操作系统下,自带wget命令. Windows操作系统下,需要自己去下载并配 ...
- 面向对象+闭包+三种对象的声明方式(字面式、new Object、构造函数、工厂模式、原型模式、混合模式)
面向对象: 对代码的一种抽象,对外统一提供调用接口的编程思想 对象的属性:事物自身拥有的东西 对象的方法:事物的功能 对象:事物的一个实例 对象的原型:.prototype -> 内存地址 -& ...
- Your idea evaluation has expired. Your session will be limited to 30 minutes
今天打开idea,出现了上面的话,试了网上的很多办法,获取注册码的那个方法是最常见的,那个网站现在不提供注册码了. ----两种方法-----**1)把提示框的x点掉,会自动打开idea**按最开始安 ...
- You are my great sunshine
"何为孤寂?" "清风,艳日,无笑意." "可否具体?" "左拥,右抱,无情欲." "可否再具体?" ...
- cobaltstrike使用笔记2
0x01 cs服务端绕过流量检测 定义C2的通信格式,修改CS默认的流量特征 编写Profiles: 开源Profiles:https://github.com/rsmudge/Malleable-C ...
- Html介绍,如何用代码展示我制作的第一个网页?
一般来说,第一次制作个人网页的朋友们,首句基本都是你好,全世界hello world 代码展示如下: <!DOCTYPE HTML> <html> <head> & ...