今日任务安排
- 各组员依照昨天分配的任务,学习自己的负责的模块的相关知识,自己上网查询或交流学习,主要学习数据库相关内容、Java语法学习,Java后端设计、WEB前端设计如CSS样表语法、JS语法等。
- 开会确定每个人撰写的前端和后端部分代码以及数据库部分代码
开始撰写具体的代码
遇到的困难
由于有关于web前端后端的知识我们根本没学过,因此只能一边学一边编写代码了。一开始对于代码的编写非常的生疏,后来在解决多次报错后也慢慢熟练了。
今日成果
CheckerController.java:
package controller;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import pojo.CRUDHelper;
public class DepartmentController extends HttpServlet {
/**
* Constructor of the object.
*/
public DepartmentController() {
super();
}
/**
* Destruction of the servlet. <br>
*/
@Override
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=gb2312");
request.setCharacterEncoding("gb2312");
CRUDHelper ib = new CRUDHelper();
String name = request.getParameter("name");
String sql = "insert into dep(name) values('"+name+"')";
int responseText = ib.insertANDupdateANDdel(sql);
if(responseText == -1 ){
request.setAttribute("message","'添加失败,学院名或存在'");
}else{
request.setAttribute("message","'添加成功'");
}
request.getRequestDispatcher("/admin/dep.jsp").forward(request, response);
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
@Override
public void init() throws ServletException {
// Put your code here
}
}
DeleteController:
package controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import pojo.CRUDHelper;
import javax.servlet.RequestDispatcher;
public class DeleteController extends HttpServlet {
/**
* Constructor of the object.
*/
public DeleteController() {
super();
}
/**
* Destruction of the servlet. <br>
*/
@Override
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=gb2312");
request.setCharacterEncoding("gb2312");
String sql = "";
String str = "";
CRUDHelper ib = new CRUDHelper();
String admin = request.getParameter("admin");
String dep = request.getParameter("dep");
String document = request.getParameter("document");
if(admin != null && !admin.equals("")){
sql = "delete from examine where document in (select id from document where admin="+admin+")";
ib.insertANDupdateANDdel(sql);
sql = "delete from document where admin="+admin;
ib.insertANDupdateANDdel(sql);
sql = "delete from admin where id="+admin;
ib.insertANDupdateANDdel(sql);
str = "/admin/systemuser.jsp";
}
if(dep != null && !dep.equals("")){
sql = "delete from examine where dep in (select id from document where dep="+dep+")";
ib.insertANDupdateANDdel(sql);
sql = "delete from examine where dep="+dep;
ib.insertANDupdateANDdel(sql);
sql = "delete from document where dep="+dep;
ib.insertANDupdateANDdel(sql);
sql = "delete from dep where id="+dep;
ib.insertANDupdateANDdel(sql);
str = "/admin/dep.jsp";
}
if(document != null && !document.equals("")){
sql = "delete from examine where document="+document;
ib.insertANDupdateANDdel(sql);
sql = "delete from document where id="+document;
ib.insertANDupdateANDdel(sql);
str = "/admin/document.jsp";
}
request.getRequestDispatcher(str).forward(request, response);
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occure
*/
@Override
public void init() throws ServletException {
// Put your code here
}
}
DepartmentController:
package controller;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import pojo.CRUDHelper;
public class DepartmentController extends HttpServlet {
/**
* Constructor of the object.
*/
public DepartmentController() {
super();
}
/**
* Destruction of the servlet. <br>
*/
@Override
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=gb2312");
request.setCharacterEncoding("gb2312");
CRUDHelper ib = new CRUDHelper();
String name = request.getParameter("name");
String sql = "insert into dep(name) values('"+name+"')";
int responseText = ib.insertANDupdateANDdel(sql);
if(responseText == -1 ){
request.setAttribute("message","'添加失败,学院名或存在'");
}else{
request.setAttribute("message","'添加成功'");
}
request.getRequestDispatcher("/admin/dep.jsp").forward(request, response);
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
@Override
public void init() throws ServletException {
// Put your code here
}
}
SQLConnection:
package helper;
import java.sql.*;
public class SQLConnection {
static String dbDriver="com.mysql.jdbc.Driver";
static{
try{
//Class.forName(dbDriver).newInstance();
// Class.forName("com.mysql.jdbc.Driver");
// Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(Exception ex){
System.out.print("---------------------om.microsoft.sqlserver.jdbc.SQLServerDri");
ex.printStackTrace();
}
}
public static Connection getConn(){
try{
Class.forName(dbDriver).newInstance();
Connection conn=DriverManager.getConnection("jdbc:mysql://127.0.0.1/gwlzxt?user=root&password=123456&useUnicode=true&characterEncoding=GBK");
// Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/northwind","root","123");
// Connection conn=DriverManager.getConnection("jdbc:odbc:twtweb");
return conn;
}catch(Exception ex){
ex.printStackTrace();
return null;
}
}
public static void close(Connection conn,Statement st,ResultSet rs){
if(rs!=null){
try{
rs.close();
}catch(SQLException ex){
}
}
if(st!=null){
try {
st.close();
}catch(Exception ex){
}
}
if(conn!=null){
try{
conn.close();
}catch(Exception ex){
}
}
}
}
今日工作量
任家萱 | 陈俊积 | 李俊龙 | 李杰 |
---|---|---|---|
4h | 4.5h | 4.5h | 4h |