勉强写完了
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.
标签:JAVA,String,上机,resp,req,getParameter,2021,return,public From: https://www.cnblogs.com/JIANGzihao0222/p/17004438.html