Merge remote-tracking branch 'remotes/origin/master' into wlf

# Conflicts:
#	src/servlet/account/Register.java
wlf
wlf 7 years ago
commit 074cef61da

File diff suppressed because it is too large Load Diff

@ -17,10 +17,18 @@
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="jdk" jdkName="11" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Tomcat 8.5.37" level="application_server_libraries" />
<orderEntry type="library" exported="" name="lib" level="project" /> <orderEntry type="library" exported="" name="lib" level="project" />
<orderEntry type="library" exported="" scope="PROVIDED" name="Tomcat 9.0.13" level="application_server_libraries" /> <orderEntry type="library" exported="" scope="PROVIDED" name="Tomcat 9.0.13" level="application_server_libraries" />
<orderEntry type="module-library" exported="">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/out/artifacts/GDMS_war_exploded/WEB-INF/lib/tomcat-jdbc.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component> </component>
</module> </module>

@ -17,9 +17,8 @@ public class DownloadFile extends Operation{
String field = core.operation.utils.Utils.getFileField(table); String field = core.operation.utils.Utils.getFileField(table);
List<String> ls = new ArrayList<>(); List<String> ls = new ArrayList<>();
ls.add(field); ls.add(field);
ResultSet rs = DBManagement.select(ls,table,limits,0,1); List<String[]> resultLs = DBManagement.select(ls,table,limits,0,1);
rs.next(); String filePath = resultLs.get(0)[0];
String filePath = rs.getString(0);
File file = new File(filePath); File file = new File(filePath);
this.getOptions().put("file",file); this.getOptions().put("file",file);
return this.getOptions(); return this.getOptions();

@ -17,17 +17,7 @@ public class Search extends Operation {
Map<String, String> limits = (Map<String, String>)this.getOptions().get("limits"); Map<String, String> limits = (Map<String, String>)this.getOptions().get("limits");
int start = (int)this.getOptions().get("start"); int start = (int)this.getOptions().get("start");
int end = (int)this.getOptions().get("end"); int end = (int)this.getOptions().get("end");
ResultSet rs = DBManagement.select(fields,table,limits,start,end); List<String[]> ls = DBManagement.select(fields,table,limits,start,end);
ResultSetMetaData rsm = rs.getMetaData() ;
int columnCount = rsm.getColumnCount();
List<String[]> ls = new ArrayList<>();
while(rs.next()){
String[] s = new String[columnCount];
for(int i=0;i<columnCount;i++){
s[i] = rs.getString(i);
}
ls.add(s);
}
this.getOptions().put("result",ls); this.getOptions().put("result",ls);
return this.getOptions(); return this.getOptions();
} }

@ -28,9 +28,8 @@ public class UploadFileOperation extends Operation {
List<String> ls = new ArrayList<>(); List<String> ls = new ArrayList<>();
ls.add(field); ls.add(field);
ResultSet rs = DBManagement.select(ls,table,limits,0,1); List<String[]> resultLs = DBManagement.select(ls,table,limits,0,1);
rs.next(); String lastFilePath = resultLs.get(0)[0];
String lastFilePath = rs.getString(0);
new File(lastFilePath).delete(); new File(lastFilePath).delete();
DBManagement.update(table,vMap,limits); DBManagement.update(table,vMap,limits);
return this.getOptions(); return this.getOptions();

@ -1,22 +1,46 @@
package core.process; package core.process;
import core.operation.Select; import core.operation.Select;
import error.GExcptInit;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public class C_StudentSelectTeacher extends core.process.Process { public class C_StudentSelectTeacher extends TempProcess {
public void select(String studentID,String teacherID)throws Exception{ String studentId;
String teacherId;
public void select()throws Exception{
if(!check()) throw new GExcptInit("ID Attrs init error!");
Select select=new Select(); Select select=new Select();
select.setOptions(new HashMap<>()); select.setOptions(new HashMap<>());
String student_id=studentID; select.addOptions("student_id",this.getStudentId());
select.addOptions("student_id",student_id); select.addOptions("teacher_id",this.getTeacherId());
String teacher_id=teacherID;
select.addOptions("teacher_id",teacher_id);
Map<String,Object> options=select.execute(null); Map<String,Object> options=select.execute(null);
} }
protected boolean check() {
if(this.getStudentId()==null||this.getTeacherId()==null)
return false;
return true;
}
public String getTeacherId() {
return teacherId;
}
public void setTeacherId(String teacherId) {
this.teacherId = teacherId;
}
public String getStudentId() {
return studentId;
}
public void setStudentId(String studentId) {
this.studentId = studentId;
}
} }

@ -0,0 +1,4 @@
package core.process;
public class C_StudentUploadOpeningReport {
}

@ -1,33 +1,46 @@
package core.process; package core.process;
import core.operation.Select; import core.operation.Select;
import error.GExcptInit;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public class C_TeacherSelectStudent extends Process { public class C_TeacherSelectStudent extends TempProcess {
List<String> list; String studentId;
String teacherId;
public C_TeacherSelectStudent clone(){
C_TeacherSelectStudent tst = new C_TeacherSelectStudent(); public void select()throws Exception{
tst.setInfo( this.getInfo()); if(!check()) throw new GExcptInit("ID Attrs init error!");
List<String> list = new ArrayList<>();
for(String s:this.list){
list.add(new String(s));
}
return null;
}
public void select(String teacherID,String studentID)throws Exception{
Select select=new Select(); Select select=new Select();
select.setOptions(new HashMap<>()); select.setOptions(new HashMap<>());
String teacher_id=teacherID; select.addOptions("teacher_id",this.getTeacherId());
select.addOptions("teacher_id",teacher_id); select.addOptions("student_id",this.getStudentId());
String student_id=studentID;
select.addOptions("student_id",student_id);
Map<String,Object> options=select.execute(null); Map<String,Object> options=select.execute(null);
} }
protected boolean check() {
if(this.getStudentId()==null||this.getTeacherId()==null)
return false;
return true;
}
public String getTeacherId() {
return teacherId;
}
public void setTeacherId(String teacherId) {
this.teacherId = teacherId;
}
public String getStudentId() {
return studentId;
}
public void setStudentId(String studentId) {
this.studentId = studentId;
}
} }

@ -30,7 +30,7 @@ public class ProcessManagement {
//Map<graduation_design_id.x_status,status> //Map<graduation_design_id.x_status,status>
public static Map<String,Character> getStatus(User user){ public static Map<String,Character> getStatus(User user){
Map<String,String> userTables = DBManagement.getUserTables(user.getType()); Map<String,String> userTables = DBManagement.getUserStatusTables(user.getType());
String graduationDesignId = null; String graduationDesignId = null;
for(Map.Entry<String,String> entry:userTables.entrySet()){ for(Map.Entry<String,String> entry:userTables.entrySet()){
String[] ti = entry.getKey().split("."); String[] ti = entry.getKey().split(".");

@ -20,7 +20,7 @@ import static dao.DBManagement.userTables;
public interface AccountManagement { public interface AccountManagement {
static User login(String id, String password) throws Exception { static User login(String id, String password) throws Exception {
ResultSet rs = null; List<String[]> ls = null;
String userType = null; String userType = null;
for(String userTable:userTables){ for(String userTable:userTables){
List<String> columns = new ArrayList<>(); List<String> columns = new ArrayList<>();
@ -28,26 +28,22 @@ public interface AccountManagement {
Map<String,String> limits = new HashMap<>(); Map<String,String> limits = new HashMap<>();
limits.put("id",id); limits.put("id",id);
try { try {
rs = DBManagement.select(columns,userTable,limits,0,1); ls = DBManagement.select(columns,userTable,limits,0,1);
} catch (Exception e) { } catch (Exception e) {
throw new GExcptSQL("QUERY\n\t"+id+"\nfailure"); throw new GExcptSQL("QUERY\n\t"+id+"\nfailure");
} }
if(rs!=null){ if(ls.size()!=0){
userType = userTable; userType = userTable;
break; break;
} }
} }
if(rs==null){ String[] userInfo = ls.get(0);
throw new GExcptAccount("id "+id+"don't exists"); if(!userInfo[1].equals(password))
}
rs.next();
if(!rs.getString(2).equals(password))
throw new GExcptAccount("password wrong"); throw new GExcptAccount("password wrong");
Map<String, String> vMap = new HashMap<>(); Map<String, String> vMap = new HashMap<>();
ResultSetMetaData rsm = rs.getMetaData(); String[] info = DBManagement.getUserInfoTables(userType);
rs.next(); for(int i=0;i<userInfo.length;i++){
for(int i=0;i<rsm.getColumnCount();i++){ vMap.put(info[i],userInfo[i]);
vMap.put(rsm.getCatalogName(i),rs.getString(i));
} }
return createUser(userType,vMap); return createUser(userType,vMap);
} }

@ -1,10 +1,10 @@
package dao; package dao;
import java.sql.*; import java.sql.*;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import error.GExcptSQL; import error.GExcptSQL;
import gdms.Configuration; import gdms.Configuration;
import org.apache.tomcat.jdbc.pool.DataSource; import org.apache.tomcat.jdbc.pool.DataSource;
@ -29,6 +29,32 @@ public class DBManagement {
"graduation_design_reply", "graduation_design_reply",
"graduation_design_reply_opinion_record_score" "graduation_design_reply_opinion_record_score"
}; };
public static String[] studentInfo = {
"id",
"password",
"name",
"e_mail_location",
"phone_number",
"grade",
"profession_code"
};
public static String[] teacherInfo = {
"id",
"password",
"name",
"e_mail_location",
"phone_number",
"job_title",
"education",
"profession_code"
};
public static String[] administratorInfo = {
"id",
"password",
"name",
"e_mail_location",
"phone_number"
};
//<table1.x_id,table2.x_status> //<table1.x_id,table2.x_status>
public static Map<String,String> graduationDesignStudentTables = new HashMap<>(){ public static Map<String,String> graduationDesignStudentTables = new HashMap<>(){
{ {
@ -79,7 +105,7 @@ public class DBManagement {
} }
return null; return null;
} }
public static Map<String,String> getUserTables(String userType){ public static Map<String,String> getUserStatusTables(String userType){
if(userType.equals("student")){ if(userType.equals("student")){
return graduationDesignStudentTables; return graduationDesignStudentTables;
} }
@ -88,7 +114,18 @@ public class DBManagement {
} }
return null; return null;
} }
public static String[] getUserInfoTables(String userType){
if(userType.equals("administrator")){
return administratorInfo;
}
if(userType.equals("student")){
return studentInfo;
}
if(userType.equals("teacher")){
return teacherInfo;
}
return null;
}
public static void delete(String table, Map<String,String> limits) throws GExcptSQL { public static void delete(String table, Map<String,String> limits) throws GExcptSQL {
Delete delete = new Delete(table, limits); Delete delete = new Delete(table, limits);
String sql = delete.getSQL(); String sql = delete.getSQL();
@ -99,7 +136,7 @@ public class DBManagement {
String sql = insert.getSQL(); String sql = insert.getSQL();
update(sql); update(sql);
} }
public static ResultSet select(List<String> columns, String table, Map<String,String> limits, int startRow, int endRow) throws Exception { public static List<String[]> select(List<String> columns, String table, Map<String,String> limits, int startRow, int endRow) throws Exception {
Select select = new Select(columns,table,limits,startRow,endRow); Select select = new Select(columns,table,limits,startRow,endRow);
String sql = select.getSQL(); String sql = select.getSQL();
return query(sql); return query(sql);
@ -109,15 +146,24 @@ public class DBManagement {
String sql = update.getSQL(); String sql = update.getSQL();
update(sql); update(sql);
} }
public static ResultSet query(String sql) throws Exception { public static List<String[]> query(String sql) throws Exception {
if(!ifInit) return null; if(!ifInit) return null;
ResultSet rs = null; List<String[]> ls;
Connection con = null; Connection con = null;
try{ try{
con = DBManagement.getConnection(); con = DBManagement.getConnection();
Statement stmt = con.createStatement(); Statement stmt = con.createStatement();
rs = stmt.executeQuery(sql); ResultSet rs = stmt.executeQuery(sql);
System.out.println(rs); ResultSetMetaData rsm = rs.getMetaData() ;
int columnCount = rsm.getColumnCount();
ls = new ArrayList<>();
while(rs.next()){
String[] s = new String[columnCount];
for(int i=0;i<columnCount;i++){
s[i] = rs.getString(i+1);
}
ls.add(s);
}
} catch (SQLException e) { } catch (SQLException e) {
throw new GExcptSQL("Connect Failure"); throw new GExcptSQL("Connect Failure");
}finally { }finally {
@ -129,7 +175,7 @@ public class DBManagement {
} }
} }
} }
return rs; return ls;
} }
public static void update(String sql) throws GExcptSQL { public static void update(String sql) throws GExcptSQL {
if(!ifInit) return; if(!ifInit) return;

@ -0,0 +1,7 @@
package error;
public class GExcptInit extends GExcpt {
public GExcptInit(String info) {
super(info);
}
}

@ -0,0 +1,28 @@
package filter;
import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebFilter(filterName = "OnlineCheck",urlPatterns = "/home.jsp")
public class OnlineCheck implements Filter {
public void destroy() {
}
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {
HttpServletRequest request = (HttpServletRequest) req;
if(request.getSession().getAttribute("user")==null){
HttpServletResponse response = (HttpServletResponse) resp;
response.sendRedirect("/login.jsp");
return;
}
chain.doFilter(req, resp);
}
public void init(FilterConfig config) throws ServletException {
}
}

@ -11,14 +11,12 @@ import java.util.Map;
public class test { public class test {
public static void main(String[] args){ public static void main(String[] args){
String student_id = "001"; int i=0;
String teacher_id = "002"; do{
core.process.Process p = new C_StudentSelectTeacher(); i++;
try { System.out.println(i);
((C_StudentSelectTeacher) p).select(student_id,teacher_id); }while(i<3);
} catch (Exception e) {
e.printStackTrace();
}
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
list.add("q"); list.add("q");
list.add("w"); list.add("w");

@ -13,12 +13,13 @@ import java.io.IOException;
public class S_StudentSelectTeacher extends HttpServlet { public class S_StudentSelectTeacher extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
super.doPost(request, response); super.doPost(request, response);
String student_id=request.getParameter("id"); String teacher_id=request.getParameter("id");
User user=(User)request.getSession().getAttribute("user"); User user=(User)request.getSession().getAttribute("user");
String teacher_id=user.getId(); String student_id=user.getId();
try { try {
new C_StudentSelectTeacher().select(student_id,teacher_id); C_StudentSelectTeacher test=new C_StudentSelectTeacher();
test.setTeacherId(teacher_id);
test.setStudentId(student_id);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

@ -13,11 +13,13 @@ import java.io.IOException;
public class S_TeacherSelectStudent extends HttpServlet { public class S_TeacherSelectStudent extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
super.doPost(request, response); super.doPost(request, response);
String teacher_id=request.getParameter("id"); String student_id=request.getParameter("id");
User user=(User)request.getSession().getAttribute("user"); User user=(User)request.getSession().getAttribute("user");
String student_id=user.getId(); String teacher_id=user.getId();
try { try {
new C_TeacherSelectStudent().select(teacher_id,student_id); C_TeacherSelectStudent test=new C_TeacherSelectStudent();
test.setTeacherId(teacher_id);
test.setStudentId(student_id);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

@ -0,0 +1,15 @@
package servlet.Submit;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public class S_ScoreSubmit extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
super.doPost(request, response);
String score = request.getParameter("score");
}
}

@ -0,0 +1,21 @@
package servlet.Submit;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public class S_StudentFillTopicInformation extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
super.doPost(request, response);
String content1=new String(request.getParameter("text").getBytes("ISO8859-1"),"UTF-8");
String content2=request.getParameter("score");
try {
} catch (Exception e) {
e.printStackTrace();
}
}
}

@ -0,0 +1,43 @@
package servlet.Submit;
import core.user.User;
import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;
import java.io.IOException;
import java.util.UUID;
@WebServlet("/upload")
@MultipartConfig
//学生id+文件
public class S_StudentUploadOpeningReport extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
super.doPost(request, response);
User user=(User) request.getSession().getAttribute("user");
String student_id=user.getId();
try {
//获取上传的文件
Part part=request.getPart("file");
//获取请求的信息
String name=part.getHeader("content-disposition");
//获取上传文件的目录
String root=request.getServletContext().getRealPath("/upload");
request.setAttribute("info", "上传文件成功");
} catch (Exception e) {
e.printStackTrace();
request.setAttribute("info", "上传文件失败");
}
request.getRequestDispatcher("/upload.jsp").forward(request, response);
}
}

@ -1,5 +1,6 @@
package servlet.Submit; package servlet.Submit;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet; import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServlet;
@ -12,5 +13,11 @@ public class S_Submit extends HttpServlet {
super.doPost(request, response); super.doPost(request, response);
String content=new String(request.getParameter("text").getBytes("ISO8859-1"),"UTF-8"); String content=new String(request.getParameter("text").getBytes("ISO8859-1"),"UTF-8");
String score=request.getParameter("score"); String score=request.getParameter("score");
try {
} catch (Exception e) {
e.printStackTrace();
}
} }
} }

@ -0,0 +1,44 @@
package servlet.account;
import java.io.IOException;
import java.sql.SQLException;
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 core.user.Student;
import core.user.User;
import core.user.utils.AccountManagement;
import error.GExcptAccount;
import error.GExcptSQL;
@WebServlet("/login")
public class S_Login extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String id=request.getParameter("id");
String password=request.getParameter("password");
User user = null;
try {
user = AccountManagement.login(id,password);
} catch (GExcptSQL | SQLException gExcptSQL) {
gExcptSQL.printStackTrace();
response.sendRedirect("/op_fail.jsp");
return;
} catch (GExcptAccount gExcptAccount) {
gExcptAccount.printStackTrace();
response.sendRedirect("/op_fail.jsp");
return;
} catch (Exception e) {
e.printStackTrace();
response.sendRedirect("/op_fail.jsp");
return;
}
request.getSession().setAttribute("user",user);
response.sendRedirect("/home.jsp");
return;
}
}

@ -10,39 +10,40 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.sql.SQLException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@WebServlet("/register") @WebServlet("/register")
public class S_Register extends HttpServlet { public class S_Register extends HttpServlet {
@Override @Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
super.doPost(request, response);
Map<String,String> user_info=new HashMap<>(); Map<String,String> user_info=new HashMap<>();
String id=request.getParameter("id"); String id=request.getParameter("id");
user_info.put("id",id); user_info.put("id",id);
String name=request.getParameter("name"); String name=request.getParameter("name");
user_info.put("name",name); user_info.put("name",name);
String e_mail_location=request.getParameter("e_mail_location"); String e_mail=request.getParameter("e_mail_location");
user_info.put("e_mail_location",e_mail_location); user_info.put("e_mail_location",e_mail);
String phone_number=request.getParameter("phone_number"); String phone_number=request.getParameter("phone_number");
user_info.put("phone_number",phone_number); user_info.put("phone_number",phone_number);
String password=request.getParameter("password"); String password=request.getParameter("password");
user_info.put("password",password); user_info.put("password",password);
String userType = request.getParameter("userType");
User user=null; User user=null;
try { try {
String Identity=request.getParameter("Identity"); user = AccountManagement.register(userType,user_info);
user = AccountManagement.register(Identity,user_info);
} catch (GExcptSQL gExcptSQL) { } catch (GExcptSQL gExcptSQL) {
gExcptSQL.printStackTrace(); gExcptSQL.printStackTrace();
response.sendRedirect("/op_fail.jsp");
} catch (GExcptAccount gExcptAccount) { } catch (GExcptAccount gExcptAccount) {
gExcptAccount.printStackTrace(); gExcptAccount.printStackTrace();
response.sendRedirect("/op_fail.jsp");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
response.sendRedirect("/op_fail.jsp");
} }
//注册失败 request.getSession().setAttribute("user",user);
request.getSession().setAttribute("User",user); response.sendRedirect("/home.jsp");
request.getRequestDispatcher("/home.jsp").forward(request,response); return;
} }
} }

@ -1,37 +0,0 @@
package servlet.account;
import java.io.IOException;
import java.sql.SQLException;
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 core.user.Student;
import core.user.User;
import core.user.utils.AccountManagement;
import error.GExcptAccount;
import error.GExcptSQL;
@WebServlet("/login")
public class login extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String id=request.getParameter("id");
String password=request.getParameter("password");
User user = null;
try {
user = AccountManagement.login(id,password);
} catch (GExcptSQL | SQLException gExcptSQL) {
gExcptSQL.printStackTrace();
} catch (GExcptAccount gExcptAccount) {
gExcptAccount.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
request.getSession().setAttribute("user",user);
request.getRequestDispatcher("/home.jsp").forward(request,response);
}
}

@ -40,7 +40,7 @@
</div> </div>
<div class="register-cont"> <div class="register-cont">
<form method="post" action="login"> <form method="post" action="register">
<input class="register-input-text sno-text" type="text" name="id" <input class="register-input-text sno-text" type="text" name="id"
placeholder="学号或职工号"> placeholder="学号或职工号">
<input class="register-input-text password-text" type="password" name="password" <input class="register-input-text password-text" type="password" name="password"
@ -53,7 +53,7 @@
placeholder="请输入电话"> placeholder="请输入电话">
<input class="register-input-text check-password-text" type="password" name="password-check" <input class="register-input-text check-password-text" type="password" name="password-check"
placeholder="请确认密码"> placeholder="请确认密码">
<select class="id-check" name="usertype"> <select class="id-check" name="userType">
<option value="">身份</option> <option value="">身份</option>
<option value="student">学生</option> <option value="student">学生</option>
<option value="teacher">老师</option> <option value="teacher">老师</option>

Loading…
Cancel
Save