2021级《JAVA语言程序设计》上机考试试题
勉强写完了
Card
package Bean;
public class Card {
private String CardId;
private String CardData;
private String CourseName;
private String CourseTeacher;
private String CourseID;
private String CourseNature;
private String Credit;
private String CourseClass;
private String CourseMajor;
private String TestWay;
private String TestData;
private String TestCount;
private String TestMethod;
private String TestGrade;
private String TestEvaluation;
private String TestAnalysis;
private String Professional;
private String ProfessionalConclusion;
private String Reasonable;
private String ReasonableConclusion;
private String AuditStatus;
public Card(String cardId2, String cardData2, String courseName2, String courseTeacher2, String courseID2,
String courseNature2, String credit2, String courseClass2, String courseMajor2, String testWay2,
String testData2, String testCount2, String testMethod2, String testGrade2, String testEvaluation2,
String testAnalysis2) {
CardId = cardId2;
CardData = cardData2;
CourseName = courseName2;
CourseTeacher = courseTeacher2;
CourseID = courseID2;
CourseNature = courseNature2;
Credit = credit2;
CourseClass = courseClass2;
CourseMajor = courseMajor2;
TestWay = testWay2;
TestData = testData2;
TestCount = testCount2;
TestMethod = testMethod2;
TestGrade = testGrade2;
TestEvaluation = testEvaluation2;
TestAnalysis = testAnalysis2;
}
public Card(String cardId2, String professional2, String professionalConclusion2, String reasonable2,
String reasonableConclusion2,String auditStatus2) {
CardId = cardId2;
Professional = professional2;
ProfessionalConclusion = professionalConclusion2;
Reasonable = reasonable2;
ReasonableConclusion = reasonableConclusion2;
AuditStatus = auditStatus2;
}
public String getCardId() {
return CardId;
}
public void setCardId(String cardId) {
CardId = cardId;
}
public String getCardData() {
return CardData;
}
public void setCardData(String cardData) {
CardData = cardData;
}
public String getCourseName() {
return CourseName;
}
public void setCourseName(String courseName) {
CourseName = courseName;
}
public String getCourseTeacher() {
return CourseTeacher;
}
public void setCourseTeacher(String courseTeacher) {
CourseTeacher = courseTeacher;
}
public String getCourseID() {
return CourseID;
}
public void setCourseID(String courseID) {
CourseID = courseID;
}
public String getCourseNature() {
return CourseNature;
}
public void setCourseNature(String courseNature) {
CourseNature = courseNature;
}
public String getCredit() {
return Credit;
}
public void setCredit(String credit) {
Credit = credit;
}
public String getCourseClass() {
return CourseClass;
}
public void setCourseClass(String courseClass) {
CourseClass = courseClass;
}
public String getCourseMajor() {
return CourseMajor;
}
public void setCourseMajor(String courseMajor) {
CourseMajor = courseMajor;
}
public String getTestWay() {
return TestWay;
}
public void setTestWay(String testWay) {
TestWay = testWay;
}
public String getTestData() {
return TestData;
}
public void setTestData(String testData) {
TestData = testData;
}
public String getTestCount() {
return TestCount;
}
public void setTestCount(String testCount) {
TestCount = testCount;
}
public String getTestMethod() {
return TestMethod;
}
public void setTestMethod(String testMethod) {
TestMethod = testMethod;
}
public String getTestGrade() {
return TestGrade;
}
public void setTestGrade(String testGrade) {
TestGrade = testGrade;
}
public String getTestEvaluation() {
return TestEvaluation;
}
public void setTestEvaluation(String testEvaluation) {
TestEvaluation = testEvaluation;
}
public String getTestAnalysis() {
return TestAnalysis;
}
public void setTestAnalysis(String testAnalysis) {
TestAnalysis = testAnalysis;
}
public String getProfessional() {
return Professional;
}
public void setProfessional(String professional) {
Professional = professional;
}
public String getProfessionalConclusion() {
return ProfessionalConclusion;
}
public void setProfessionalConclusion(String professionalConclusion) {
ProfessionalConclusion = professionalConclusion;
}
public String getReasonable() {
return Reasonable;
}
public void setReasonable(String reasonable) {
Reasonable = reasonable;
}
public String getReasonableConclusion() {
return ReasonableConclusion;
}
public void setReasonableConclusion(String reasonableConclusion) {
ReasonableConclusion = reasonableConclusion;
}
public String getAuditStatus() {
return AuditStatus;
}
public void setAuditStatus(String auditStatus) {
AuditStatus = auditStatus;
}
}
Daocard
package dao;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import Bean.Card;
import Bean.Student;
import Bean.Teacher;
import util.Util;
public class DaoCard {
public static int AddCard(Card car) {
String sql = "insert into Card (CardId,CardData,CourseName,CourseTeacher,CourseID,CourseNature,Credit,CourseClass,CourseMajor,TestWay,TestData,TestCount,TestMethod,TestGrade,TestEvaluation,TestAnalysis) values('" + car.getCardId() + "','" + car.getCardData() + "','" + car.getCourseName()+ "','" + car.getCourseTeacher() + "','" + car.getCourseID() + "','" + car.getCourseNature() + "','" + car.getCredit()+ "','" + car.getCourseClass() + "','" + car.getCourseMajor()+ "','" + car.getTestWay() + "','" + car.getTestData() + "','" + car.getTestCount() + "','" + car.getTestMethod() + "','" + car.getTestGrade() + "','" +car.getTestEvaluation() + "','" + car.getTestAnalysis() +"')";
System.out.println(sql);
Connection conn = Util.getConn();
Statement state = null;
int count=0;
try {
state = conn.createStatement();
count = state.executeUpdate(sql);
} catch (Exception e) {
e.printStackTrace();
} finally {
//关闭连接
Util.close(state, conn);
}
return count;
}
public static List<Card> ViewinformationCard() {
List<Card>list=new ArrayList<Card>();
String sql = "select * from Card ";
System.out.println(sql);
Connection conn = Util.getConn();
Statement state = null;
ResultSet rs = null;
Card car=null;
try {
state = conn.createStatement();
rs = state.executeQuery(sql);
while (rs.next()) {
String CardId = rs.getString("CardId");
String Professional = rs.getString("Professional");
String ProfessionalConclusion = rs.getString("ProfessionalConclusion");
String Reasonable = rs.getString("Reasonable");
String ReasonableConclusion = rs.getString("ReasonableConclusion");
String AuditStatus = rs.getString("AuditStatus");
car = new Card(CardId,Professional,ProfessionalConclusion,Reasonable,ReasonableConclusion,AuditStatus);
System.out.println(car);
//tbean=new Beanxuesheng(zhuti,mudi,leixing,shijian,didian,duixiang,neirong,anpai);
list.add(car);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
Util.close(rs, state, conn);
}
return list;
}
public static int DeleteCard(String cardId) {
int count=0;
String sql = "delete from Card where CardId='" + cardId + "'";
Connection conn = Util.getConn();
System.out.println(sql);
Statement state = null;
try {
state = conn.createStatement();
count = state.executeUpdate(sql);
} catch (SQLException e) {
e.printStackTrace();
} finally {
Util.close(state, conn);
}
return count;
}
public static int UpdateCard(Card car) {
String sql = "update Card set CardData='" +car.getCardData()+ "',CourseName='" + car.getCourseName() + "', CourseTeacher='" + car.getCourseTeacher()+ "', CourseID='" +car.getCourseID()+ "', CourseNature='" +car.getCourseNature()+ "', Credit='" +car.getCredit()+ "', CourseClass='" +car.getCourseClass()+ "', CourseMajor='" +car.getCourseMajor()+ "', TestWay='" +car.getTestWay()+ "', TestData='" +car.getTestData()+ "', TestCount='" +car.getTestCount()+ "', TestMethod='" +car.getTestMethod()+ "', TestGrade='" +car.getTestGrade()+ "', TestEvaluation='" +car.getTestEvaluation()+ "', TestAnalysis='" +car.getTestAnalysis()
+ "' where CardID='" +car.getCardId()+ "'";
Connection conn = Util.getConn();
Statement state = null;
int count=0;
try {
state = conn.createStatement();
count = state.executeUpdate(sql);
} catch (Exception e) {
e.printStackTrace();
} finally {
//关闭连接
Util.close(state, conn);
}
if(count>0)
{
return 1;
}
else
{
return 0;
}
}
public static List<Card> EvaluateCard1() {
List<Card>list=new ArrayList<Card>();
String sql = "select * from Card ";
System.out.println(sql);
Connection conn = Util.getConn();
Statement state = null;
ResultSet rs = null;
Card car=null;
try {
state = conn.createStatement();
rs = state.executeQuery(sql);
while (rs.next()) {
String CardId = rs.getString("CardId");
String CardData= rs.getString("CardData");
String CourseName = rs.getString("CourseName");
String CourseTeacher = rs.getString("CourseTeacher");
String CourseID = rs.getString("CourseID");
String CourseNature = rs.getString("CourseNature");
String Credit = rs.getString("Credit");
String CourseClass = rs.getString("CourseClass");
String CourseMajor= rs.getString("CourseMajor");
String TestWay = rs.getString("TestWay");
String TestData = rs.getString("TestData");
String TestCount = rs.getString("TestCount");
String TestMethod = rs.getString("TestMethod");
String TestGrade = rs.getString("TestGrade");
String TestEvaluation=rs.getString("TestEvaluation");
String TestAnalysis = rs.getString("TestAnalysis");
car=new Card(CardId,CardData,CourseName,CourseTeacher,CourseID,CourseNature,Credit,CourseClass,CourseMajor,TestWay,TestData,TestCount,TestMethod,TestGrade,TestEvaluation,TestAnalysis);
System.out.println(car);
//tbean=new Beanxuesheng(zhuti,mudi,leixing,shijian,didian,duixiang,neirong,anpai);
list.add(car);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
Util.close(rs, state, conn);
}
return list;
}
public static int EvaluateCard111(String cardId, String address) {
String sql = "update Card set Professional='" +address+ "' where CardID='" +cardId+ "'";
System.out.println(sql);
Connection conn = Util.getConn();
Statement state = null;
int count=0;
try {
state = conn.createStatement();
count = state.executeUpdate(sql);
} catch (Exception e) {
e.printStackTrace();
} finally {
//关闭连接
Util.close(state, conn);
}
if(count>0)
{
return 1;
}
else
{
return 0;
}
}
public static int EvaluateCard121(String cardId, String address) {
String sql = "update Card set ProfessionalConclusion='" +address+ "' where CardID='" +cardId+ "'";
System.out.println(sql);
Connection conn = Util.getConn();
Statement state = null;
int count=0;
try {
state = conn.createStatement();
count = state.executeUpdate(sql);
} catch (Exception e) {
e.printStackTrace();
} finally {
//关闭连接
Util.close(state, conn);
}
if(count>0)
{
return 1;
}
else
{
return 0;
}
}
public static int Pass(String cardId) {
String sql = "update Card set AuditStatus='" +"通过"+ "' where CardID='" +cardId+ "'";
System.out.println(sql);
Connection conn = Util.getConn();
Statement state = null;
int count=0;
try {
state = conn.createStatement();
count = state.executeUpdate(sql);
} catch (Exception e) {
e.printStackTrace();
} finally {
//关闭连接
Util.close(state, conn);
}
if(count>0)
{
return 1;
}
else
{
return 0;
}
}
public static int EvaluateCard21(String cardId, String address, String conclusion) {
String sql = "update Card set Reasonable='" +address+ "',ReasonableConclusion='" + conclusion + "', AuditStatus='" +"通过通过"
+ "' where CardID='" +cardId+ "'";
System.out.println(sql);
Connection conn = Util.getConn();
Statement state = null;
int count=0;
try {
state = conn.createStatement();
count = state.executeUpdate(sql);
} catch (Exception e) {
e.printStackTrace();
} finally {
//关闭连接
Util.close(state, conn);
}
if(count>0)
{
return 1;
}
else
{
return 0;
}
}
}
Servlet
package servlet;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import Bean.Card;
import Bean.Student;
import Bean.Teacher;
import service.Service;
/**
* Servlet implementation class Servlet
*/
@WebServlet("/Servlet")
public class Servlet extends HttpServlet {
private static final long serialVersionUID = 1L;
Service service=new Service();
/**
* @see HttpServlet#HttpServlet()
*/
public Servlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("utf-8");
String method = req.getParameter("method");
if ("Login".equals(method)) {
Login(req, resp);
}
if ("ViewinformationStudent".equals(method)) {
ViewinformationStudent(req, resp);
}
if ("updataStudent".equals(method)) {
updataStudent(req, resp);
}
if ("Register".equals(method)) {
Register(req, resp);
}
if ("Examineinformation".equals(method)) {
Examineinformation(req, resp);
}
if ("Allow".equals(method)) {
Allow(req, resp);
}
if ("ResetStudent".equals(method)) {
ResetStudent(req, resp);
}
if ("ViewinformationManager".equals(method)) {
ViewinformationManager(req, resp);
}
if ("AddTeacher".equals(method)) {
AddTeacher(req, resp);
}
if ("AddCard".equals(method)) {
AddCard(req, resp);
}
if ("ViewinformationCard".equals(method)) {
ViewinformationCard(req, resp);
}
if ("UpdateCard1".equals(method)) {
UpdateCard1(req, resp);
}
if ("UpdateCard".equals(method)) {
UpdateCard(req, resp);
}
if ("DeleteCard".equals(method)) {
DeleteCard(req, resp);
}
if ("EvaluateCard1".equals(method)) {
EvaluateCard1(req, resp);
}
if ("EvaluateCard11".equals(method)) {
EvaluateCard11(req, resp);
}
if ("EvaluateCard111".equals(method)) {
EvaluateCard111(req, resp);
}
if ("EvaluateCard12".equals(method)) {
EvaluateCard12(req, resp);
}
if ("EvaluateCard121".equals(method)) {
EvaluateCard121(req, resp);
}
if ("Pass".equals(method)) {
Pass(req, resp);
}
if ("EvaluateCard2".equals(method)) {
EvaluateCard2(req, resp);
}
if ("EvaluateCard21".equals(method)) {
EvaluateCard21(req, resp);
}
if ("EvaluateCard212".equals(method)) {
EvaluateCard212(req, resp);
}
}
private void EvaluateCard21(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
HttpSession session=req.getSession();
String CardId= req.getParameter("CardId");
session.setAttribute("CardId",CardId);
req.getRequestDispatcher("EvaluateCard21.jsp").forward(req,resp);
}
private void EvaluateCard212(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("utf-8");
HttpSession session=req.getSession();
String CardId=(String)session.getAttribute("CardId");
String address= req.getParameter("address");
String Conclusion= req.getParameter("Conclusion");
if(service.EvaluateCard21(CardId,address,Conclusion)==1)
{
req.setAttribute("message", "通过");
req.getRequestDispatcher("EvaluateCard2.jsp").forward(req,resp);
}
else
{
req.setAttribute("message", "未通过");
req.getRequestDispatcher("EvaluateCard2.jsp").forward(req,resp);
}
}
private void EvaluateCard2(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("utf-8");
List<Card> bean = new ArrayList<Card>();
bean=service.EvaluateCard1();
req.setAttribute("bean", bean);
System.out.println(bean);
req.getRequestDispatcher("EvaluateCard2.jsp").forward(req,resp);
}
private void Pass(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("utf-8");
String CardId= req.getParameter("CardId");
if(service.Pass(CardId)==1)
{
req.setAttribute("message", "通过");
req.getRequestDispatcher("EvaluateCard1.jsp").forward(req,resp);
}
else
{
req.setAttribute("message", "未通过");
req.getRequestDispatcher("EvaluateCard1.jsp").forward(req,resp);
}
}
private void EvaluateCard121(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("utf-8");
String address= req.getParameter("address");
HttpSession session=req.getSession();
String CardId=(String)session.getAttribute("CardId");
if(service.EvaluateCard121(CardId,address)==1)
{
req.setAttribute("message", "添加成功");
req.getRequestDispatcher("EvaluateCard1.jsp").forward(req,resp);
}
else
{
req.setAttribute("message", "添加失败");
req.getRequestDispatcher("EvaluateCard1.jsp").forward(req,resp);
}
}
private void EvaluateCard12(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("utf-8");
String CardId= req.getParameter("CardId");
HttpSession session=req.getSession();
session.setAttribute("CardId",CardId);
req.getRequestDispatcher("EvaluateCard12.jsp").forward(req,resp);
}
private void EvaluateCard111(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("utf-8");
String address= req.getParameter("address");
HttpSession session=req.getSession();
String CardId=(String)session.getAttribute("CardId");
if(service.EvaluateCard111(CardId,address)==1)
{
req.setAttribute("message", "添加成功");
req.getRequestDispatcher("EvaluateCard1.jsp").forward(req,resp);
}
else
{
req.setAttribute("message", "添加失败");
req.getRequestDispatcher("EvaluateCard1.jsp").forward(req,resp);
}
}
private void EvaluateCard11(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("utf-8");
String CardId= req.getParameter("CardId");
HttpSession session=req.getSession();
session.setAttribute("CardId",CardId);
req.getRequestDispatcher("EvaluateCard11.jsp").forward(req,resp);
}
private void EvaluateCard1(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("utf-8");
List<Card> bean = new ArrayList<Card>();
bean=service.EvaluateCard1();
req.setAttribute("bean", bean);
System.out.println(bean);
req.getRequestDispatcher("EvaluateCard1.jsp").forward(req,resp);
}
private void UpdateCard(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("utf-8");
HttpSession session=req.getSession();
String CardId=(String)session.getAttribute("CardId");
String CardData= req.getParameter("CardData");
String CourseName = req.getParameter("CourseName");
String CourseTeacher = req.getParameter("CourseTeacher");
String CourseID = req.getParameter("CourseID");
String CourseNature = req.getParameter("CourseNature");
String Credit = req.getParameter("Credit");
String CourseClass = req.getParameter("CourseClass");
String CourseMajor= req.getParameter("CourseMajor");
String TestWay = req.getParameter("TestWay");
String TestData = req.getParameter("TestData");
String TestCount = req.getParameter("TestCount");
String TestMethod = req.getParameter("TestMethod");
String TestGrade = req.getParameter("TestGrade");
String TestEvaluation= req.getParameter("TestEvaluation");
String TestAnalysis = req.getParameter("TestAnalysis");
Card car=new Card(CardId,CardData,CourseName,CourseTeacher,CourseID,CourseNature,Credit,CourseClass,CourseMajor,TestWay,TestData,TestCount,TestMethod,TestGrade,TestEvaluation,TestAnalysis);
if(service.UpdateCard(car)==1)
{
req.setAttribute("message", "修改成功");
req.getRequestDispatcher("Teacher.jsp").forward(req,resp);
}else
{
req.setAttribute("message", "修改失败");
req.getRequestDispatcher("ViewinformationCard.jsp").forward(req,resp);
}
}
private void DeleteCard(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// TODO Auto-generated method stub
req.setCharacterEncoding("utf-8");
String CardId = req.getParameter("CardId");
if(service.DeleteCard(CardId)==1)
{
req.setAttribute("message", "删除成功");
req.getRequestDispatcher("Teacher.jsp").forward(req,resp);
}else
{
req.setAttribute("message", "删除失败");
req.getRequestDispatcher("ViewinformationCard.jsp").forward(req,resp);
}
}
private void UpdateCard1(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// TODO Auto-generated method stub
req.setCharacterEncoding("utf-8");
String CardId = req.getParameter("CardId");
HttpSession session=req.getSession();
session.setAttribute("CardId",CardId);
req.getRequestDispatcher("UpdateCard.jsp").forward(req,resp);
}
private void ViewinformationCard(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("utf-8");
List<Card> bean = new ArrayList<Card>();
bean=service.ViewinformationCard();
req.setAttribute("bean", bean);
System.out.println(bean);
req.getRequestDispatcher("ViewinformationCard.jsp").forward(req,resp);
}
private void AddCard(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("utf-8");
String CardId = req.getParameter("CardId");
String CardData= req.getParameter("CardData");
String CourseName = req.getParameter("CourseName");
String CourseTeacher = req.getParameter("CourseTeacher");
String CourseID = req.getParameter("CourseID");
String CourseNature = req.getParameter("CourseNature");
String Credit = req.getParameter("Credit");
String CourseClass = req.getParameter("CourseClass");
String CourseMajor= req.getParameter("CourseMajor");
String TestWay = req.getParameter("TestWay");
String TestData = req.getParameter("TestData");
String TestCount = req.getParameter("TestCount");
String TestMethod = req.getParameter("TestMethod");
String TestGrade = req.getParameter("TestGrade");
String TestEvaluation= req.getParameter("TestEvaluation");
String TestAnalysis = req.getParameter("TestAnalysis");
Card car=new Card(CardId,CardData,CourseName,CourseTeacher,CourseID,CourseNature,Credit,CourseClass,CourseMajor,TestWay,TestData,TestCount,TestMethod,TestGrade,TestEvaluation,TestAnalysis);
if(service.AddCard(car)==1)
{
req.setAttribute("message", "添加成功");
req.getRequestDispatcher("Teacher.jsp").forward(req,resp);
}else
{
req.setAttribute("message", "添加失败");
req.getRequestDispatcher("AddCard.jsp").forward(req,resp);
}
}
private void AddTeacher(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("utf-8");
String TeacherID = req.getParameter("TeacherID");
String Name= req.getParameter("Name");
String College = req.getParameter("College");
String Professionals = req.getParameter("Professionals");
String Role = req.getParameter("Role");
String Mima = req.getParameter("Mima");
Teacher tea=new Teacher(TeacherID,Name,College,Professionals,Role,Mima);
if(service.AddTeacher(tea)==1)
{
req.setAttribute("message", "添加成功");
req.getRequestDispatcher("Manager.jsp").forward(req,resp);
}else
{
req.setAttribute("message", "添加失败");
req.getRequestDispatcher("Addteacher.jsp").forward(req,resp);
}
}
private void ViewinformationManager(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("utf-8");
List<Student> bean = new ArrayList<Student>();
bean=service.ViewinformationManager();
req.setAttribute("bean", bean);
System.out.println(bean);
req.getRequestDispatcher("ViewinformationManager.jsp").forward(req,resp);
}
private void ResetStudent(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("utf-8");
String StuID = req.getParameter("StuID");
if(service.ResetStudent(StuID)==1)
{ req.setAttribute("message", "成功");
req.getRequestDispatcher("Manager.jsp").forward(req,resp);
}
else
{
req.setAttribute("message", "失败");
req.getRequestDispatcher("ViewinformationManager.jsp").forward(req,resp);
}
}
private void Allow(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("utf-8");
String StuID = req.getParameter("StuID");
if(service.Allow(StuID)==1)
{ req.setAttribute("message", "通过");
req.getRequestDispatcher("Manager.jsp").forward(req,resp);
}
else
{
req.setAttribute("message", "未通过");
req.getRequestDispatcher("Examineinformation.jsp").forward(req,resp);
}
}
private void Examineinformation(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("utf-8");
List<Student> bean = new ArrayList<Student>();
bean=service.Examineinformation();
req.setAttribute("bean", bean);
System.out.println(bean);
req.getRequestDispatcher("Examineinformation.jsp").forward(req,resp);
}
private void Register(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("utf-8");
String StuID = req.getParameter("StuID");
System.out.println(StuID);
String StuName = req.getParameter("StuName");
String sex = req.getParameter("sex");
String College = req.getParameter("College");
String Professionals = req.getParameter("Professionals");
String Phone = req.getParameter("Phone");
String Position = req.getParameter("Position");
String Mima = req.getParameter("Mima");
String Situation="未通过";
Student stu = new Student(StuID,StuName,sex,College,Professionals,Phone,Position,Mima,Situation);
if(service.Register(stu)==1)
{ req.setAttribute("message", "注册成功");
req.getRequestDispatcher("Student.jsp").forward(req,resp);
}
else
{
req.setAttribute("message", "注册失败,请重试");
req.getRequestDispatcher("Student.jsp").forward(req,resp);
}
}
private void updataStudent(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("utf-8");
String mima1 = req.getParameter("mima1");
String mima2 = req.getParameter("mima2");
String mima3 = req.getParameter("mima3");
HttpSession session=req.getSession();
String StuID=(String)session.getAttribute("StuID");
String Mima=(String)session.getAttribute("Mima");
if(mima1.equals(Mima))
{
if(mima2.equals(mima3))
{
if(service.updataStudent(StuID,mima2)==1)
{
req.setAttribute("message", "修改成功");
session.setAttribute("Mima",mima2);
req.getRequestDispatcher("Student.jsp").forward(req,resp);
}
}
req.setAttribute("message", "新密码不相同");
req.getRequestDispatcher("updataStudent.jsp").forward(req,resp);
}
req.setAttribute("message", "原密码错误,请重试");
req.getRequestDispatcher("updataStudent.jsp").forward(req,resp);
}
private void ViewinformationStudent(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("utf-8");
HttpSession session=req.getSession();
String StuID=(String)session.getAttribute("StuID");
System.out.println(StuID);
String Mima=(String)session.getAttribute("Mima");
if(service.LoginStudent(StuID,Mima)==1)
{
Student stu=null;
//List<Beankecheng> bean = new ArrayList<Beankecheng>();
stu=service.ViewinformationStudent(StuID);
req.setAttribute("bean", stu);
req.getRequestDispatcher("ViewinformationStudent.jsp").forward(req,resp);
}
else
{
req.setAttribute("message", "查看失败,请重试");
req.getRequestDispatcher("Student.jsp").forward(req,resp);
}
}
private void Login(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("utf-8");
String zhiye = req.getParameter("zhiye");
String hao = req.getParameter("hao");
String Mima = req.getParameter("Mima");
HttpSession session=req.getSession();
if(zhiye.equals("学生"))
{ session.setAttribute("StuID",hao);
session.setAttribute("Mima",Mima);
String Situation=service.Judge(hao);
if((service.LoginStudent(hao,Mima)==1)&&(Situation.equals("通过")))
{
req.setAttribute("message", "登录成功");
req.getRequestDispatcher("Student.jsp").forward(req,resp);
}
else
{
req.setAttribute("message", "登录失败,请重新登录");
req.getRequestDispatcher("Screen.jsp").forward(req,resp);
}
}
if(zhiye.equals("专业教师"))
{
session.setAttribute("TeacherID",hao);
session.setAttribute("Mima",Mima);
String Role=service.JudgeRole(hao);
if((service.LoginTeacher(hao,Mima)==1)&&(Role.equals("001")))
{
req.setAttribute("message", "登录成功");
req.getRequestDispatcher("Teacher.jsp").forward(req,resp);
}
else
{
req.setAttribute("message", "登录失败,请重新登录");
req.getRequestDispatcher("Screen.jsp").forward(req,resp);
}
}
if(zhiye.equals("专业负责人"))
{
session.setAttribute("TeacherID",hao);
session.setAttribute("Mima",Mima);
String Role=service.JudgeRole(hao);
if((service.LoginTeacher(hao,Mima)==1)&&(Role.equals("011")))
{
req.setAttribute("message", "登录成功");
req.getRequestDispatcher("Teacher1.jsp").forward(req,resp);
}
else
{
req.setAttribute("message", "登录失败,请重新登录");
req.getRequestDispatcher("Screen.jsp").forward(req,resp);
}
}
if(zhiye.equals("教学副院长"))
{session.setAttribute("TeacherID",hao);
session.setAttribute("Mima",Mima);
String Role=service.JudgeRole(hao);
if((service.LoginTeacher(hao,Mima)==1)&&(Role.equals("111")))
{
req.setAttribute("message", "登录成功");
req.getRequestDispatcher("Teacher2.jsp").forward(req,resp);
}
else
{
req.setAttribute("message", "登录失败,请重新登录");
req.getRequestDispatcher("Screen.jsp").forward(req,resp);
}
}
if(zhiye.equals("管理员"))
{
if((hao.equals("1"))&&Mima.equals("jiangzihao"))
{
req.setAttribute("message", "登录成功");
req.getRequestDispatcher("Manager.jsp").forward(req,resp);
}
else
{
req.setAttribute("message", "登录失败,请重新登录");
req.getRequestDispatcher("Screen.jsp").forward(req,resp);
}
}
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
Service
package service;
import java.util.List;
import Bean.Card;
import Bean.Student;
import Bean.Teacher;
import dao.DaoCard;
import dao.DaoStudent;
import dao.DaoTeacher;
public class Service {
public int LoginStudent(String stuID, String Mima) {
return DaoStudent.LoginStudent(stuID,Mima);
}
public Student ViewinformationStudent(String stuID) {
return DaoStudent.ViewinformationStudent(stuID);
}
public int updataStudent(String stuID, String mima) {
if(DaoStudent.updataStudent(stuID,mima)>0)
return 1;
return 0;
}
public int Register(Student stu) {
if(DaoStudent.Register(stu)>0)
return 1;
return 0;
}
public String Judge(String hao) {
return DaoStudent.Judge(hao);
}
public List<Student> Examineinformation() {
return DaoStudent.Examineinformation();
}
public int Allow(String stuID) {
if(DaoStudent.Allow(stuID)>0)
return 1;
return 0;
}
public int ResetStudent(String stuID) {
if(DaoStudent.ResetStudent(stuID)>0)
return 1;
return 0;
}
public List<Student> ViewinformationManager() {
return DaoStudent.ViewinformationManager();
}
public int AddTeacher(Teacher tea) {
if(DaoTeacher.AddTeacherr(tea)>0)
return 1;
return 0;
}
public String JudgeRole(String hao) {
// TODO Auto-generated method stub
return DaoTeacher.JudgeRole(hao);
}
public int LoginTeacher(String hao, String mima) {
if(DaoTeacher.LoginTeacher(hao,mima)>0)
return 1;
return 0;
}
public int AddCard(Card car) {
if(DaoCard.AddCard(car)>0)
return 1;
return 0;
}
public List<Card> ViewinformationCard() {
// TODO Auto-generated method stub
return DaoCard.ViewinformationCard();
}
public int DeleteCard(String cardId) {
// TODO Auto-generated method stub
if(DaoCard.DeleteCard(cardId)>0)
return 1;
return 0;
}
public int UpdateCard(Card car) {
// TODO Auto-generated method stub
if(DaoCard.UpdateCard(car)>0)
return 1;
return 0;
}
public List<Card> EvaluateCard1() {
// TODO Auto-generated method stub
return DaoCard.EvaluateCard1();
}
public int EvaluateCard111(String cardId, String address) {
if(DaoCard.EvaluateCard111(cardId,address)>0)
return 1;
return 0;
}
public int EvaluateCard121(String cardId, String address) {
if(DaoCard.EvaluateCard121(cardId,address)>0)
return 1;
return 0;
}
public int Pass(String cardId) {
if(DaoCard.Pass(cardId)>0)
return 1;
return 0;
}
public int EvaluateCard21(String cardId, String address, String conclusion) {
if(DaoCard.EvaluateCard21(cardId,address,conclusion)>0)
return 1;
return 0;
}
}
这是最后的servlet和service,有肯定有遗漏的但大体完成了,写了10篇,还可以,博客应该60多了,然后就是期末感受,很。。。。。,那么短时间写不完,然后还看不懂题,有思路没时间,然后遇到一个好一点的学长给的就高,唉~~,还是菜,然后也考完了,也不用学这个了,nice.
2021级《JAVA语言程序设计》上机考试试题的更多相关文章
- Java语言程序设计-助教篇
1. 给第一次上课(软件工程)的老师与助教 现代软件工程讲义 0 课程概述 给学生:看里面的第0个作业要求 2. 助教心得 美国视界(1):第一流的本科课堂该是什么样?(看里面的助教部分) 助教工作看 ...
- 全国计算机等级考试二级笔试样卷Java语言程序设计
一.选择题((1)-(35)每小题2分,共70分) 下列各题A).B).C).D)四个选项中,只有一个选项是正确的,请将正确选项涂写在答题卡相应位置上,答在试卷上不得分. (1)下列选项中不符合良好程 ...
- 《JAVA语言程序设计》上课笔记
教学目标:1.使学生了解JAVA课程的性质.定位.作用:为什么要学习JAVA?让学生知道如何学好JAVA: 教学内容: 一. 问几个问题 1. 你们到这里来干什么 ...
- Java语言程序设计复习提纲
这是我在准备Java考试时整理的提纲,如果是通过搜索引擎搜索到这篇博客的师弟师妹,建议还是先参照PPT和课本,这个大纲也不是很准确,自己总结会更有收获,多去理解含义,不要死记硬背,否则遇到概念辨析题 ...
- 0031 Java学习笔记-梁勇著《Java语言程序设计-基础篇 第十版》英语单词
第01章 计算机.程序和Java概述 CPU(Central Processing Unit) * 中央处理器 Control Unit * 控制单元 arithmetic/logic unit /ə ...
- Java语言程序设计(基础篇)第一章
第一章 计算机.程序和Java概述 1.1 引言 什么是程序设计呢? 程序设计就是创建(或者开发)软件,软件也称为程序. 1.2 什么是计算机 计算机是存储和处理数据的电子设备,计算机包括硬件(har ...
- JAVA语言程序设计课程评价
紧张的又短暂的一个学期结束了,这个学期也许将成为我人生中一个重要的转折点,作为一名半路出家的选手,在初次了解Java语言时我感到非常的迷茫与不知所措.因为之前很多同学都是通过假期时间在家自学,刚转入新 ...
- java语言程序设计(一)-1
java 语言的特点是: 强类型,制定了比较多的语言规范,尽可能在编译阶段检测出更多的错误及警告. 编译和解释,首先将源代码编译成codebyte,运行时,java的运行系统装载和链接需要执行的类,并 ...
- IT兄弟连 Java语法教程 Java语言入门 典面试题
1.请说明JVM.JRE和JDK是什么?它们有什么关系? JVM是Java虚拟机,Java Virtual Machine的缩写,是一个虚构出来的计算机,通过在实际的计算机上仿真模拟各种计算机功能来实 ...
- 《Java语言程序设计》上机实验
实验一 Java环境演练 [目的] ①安装并配置Java运行开发环境: ②掌握开发Java应用程序的3个步骤:编写源文件.编译源文件和运行应用程序: ③学习同时编译多个Java源文件. [内容 ...
随机推荐
- ssh免交互
sshpass -p the_password ssh -o StrictHostKeyChecking=no root@domainname_or_ip remote_command #远程执行命 ...
- 4 c++编程-提高篇-STL简介
重新系统学习c++语言,并将学习过程中的知识在这里抄录.总结.沉淀.同时希望对刷到的朋友有所帮助,一起加油哦! 生命就像一朵花,要拼尽全力绽放!死磕自个儿,身心愉悦! 写在前面,本篇章主要简单介 ...
- easui 两个combobox相互选中时至对方为空的解决方案
combobox HTML: <select id="monthplan" class="zxui-combobox" name="monthp ...
- ArcGIS QGIS学习二:图层如何只显示需要的部分几何面数据(附最新坐标边界下载全国省市区县乡镇)
目录 前言 准备SHP数据 ArcMap 的筛选 QGIS 的筛选 如何编写查询条件 前言 当我们用GIS软件打开一个SHP文件的时候,会显示出里面全部的几何图形,假如我只想要其中的一部分数据显示出来 ...
- git、docker、lunix、python、pycharm等常用命令整理
git的使用 上传代码git clone ....git branch new_branchgit checkout branch_namegit add .git commit -m "& ...
- 第三方模块 request openpyxl
目录 第三方模块的下载 pip工具 简介 pip使用注意 pip位置和环境变量设置 pip安装第三方模块 使用pip下载可能会遇到的问题 pycharm的第三方模块下载功能 request模块 req ...
- 【JVM故障问题排查心得】「内存诊断系列」Docker容器经常被kill掉,k8s中该节点的pod也被驱赶,怎么分析?
背景介绍 最近的docker容器经常被kill掉,k8s中该节点的pod也被驱赶. 我有一个在主机中运行的Docker容器(也有在同一主机中运行的其他容器).该Docker容器中的应用程序将会计算数据 ...
- Anaconda下载安装
下载地址: 链接:https://pan.baidu.com/s/1fmJkMSL6amJF4KP5JwklOQ 提取码:dsyc 安装完成之后,记得配置系统环境变量:
- day01-Spring基本介绍
Spring基本介绍 1.官方资料和下载 1.1Spring5下载 直接访问 https://repo.spring.io/ui/native/release/org/springframework/ ...
- Hugging Face - 推理(Inference)解决方案
每天,开发人员和组织都在使用 Hugging Face 平台上托管的模型,将想法变成概念验证(proof-of-concept)的 demo,再将 demo 变成生产级的应用. Transformer ...