資源簡介
網頁版的學生成績管理系統,需要Tomcat,mysql等,數據庫中存在數據,可以自己添加數據。存在學生、教師和管理員三方登錄,實現基本功能

代碼片段和文件信息
package?data;
import?java.io.IOException;
import?java.sql.Connection;
import?java.sql.PreparedStatement;
import?java.sql.ResultSet;
import?java.sql.SQLException;
import?java.sql.Statement;
import?javax.servlet.ServletException;
import?javax.servlet.http.HttpServlet;
import?javax.servlet.http.HttpServletRequest;
import?javax.servlet.http.HttpServletResponse;
public?class?add?extends?HttpServlet?{
public?void?doGet(HttpServletRequest?req?HttpServletResponse?resp)
throws?ServletException?IOException?{?//?處理post請求
this.doPost(req?resp);?//?同一種方法體處理
}
protected?void?doPost(HttpServletRequest?request
HttpServletResponse?response)?throws?ServletException?IOException?{
request.setCharacterEncoding(“utf8“);
response.setCharacterEncoding(“utf8“);
Connection?conn?=?null;
Connection?conn1?=?null;
Connection?conn2?=?null;
Statement?st?=?null;
Statement?st1?=?null;
Statement?st2?=?null;
int?id?=?0;
try?{
conn?=?link.getConnection();
st?=?conn.createStatement();
String?username?=?request.getParameter(“username“);
String?password?=?request.getParameter(“password“);
String?type?=?request.getParameter(“type“);
st.execute(“insert?into?user?(username?passwordtype)?values?(‘“
+?username?+?“‘‘“?+?password?+?“‘‘“?+?type?+?“‘)“);
if?(type.equals(“1“))?{
conn1?=?link.getConnection();
st1?=?conn1.createStatement();
ResultSet?rs?=?st1
.executeQuery(“select?*?from?user?where?username?=?‘“
+?username?+?“‘?and?password?=?‘“?+?password
+?“‘“);
while?(rs.next())?{
id?=?rs.getInt(“id“);
}
conn2?=?link.getConnection();
st2?=?conn2.createStatement();
st2.execute(“insert?into?student?(idusername)?values?(‘“
+?id?+?“‘‘“?+?username?+?“‘)“);
}
response.sendRedirect(“adlist“);
}?catch?(SQLException?e)?{
e.printStackTrace();
}?finally?{
try?{
st.close();
}?catch?(Exception?e)?{
}
try?{
conn.close();
}?catch?(Exception?e)?{
}
}
}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????529??2016-11-09?21:35??databa
?????文件????????297??2016-11-23?14:10??databa
?????文件???????1751??2016-11-09?21:41??databa
?????文件????????500??2016-11-08?15:41??databa
?????文件?????????72??2016-11-10?22:28??databa
?????文件????????364??2016-11-09?21:35??databa
?????文件????????462??2016-11-09?21:35??databa
?????文件????????252??2016-11-09?21:35??databa
?????文件?????????49??2016-11-09?21:35??databa
?????文件??????????6??2016-11-09?21:35??databa
?????文件??????42702??2016-11-27?19:53??databa
?????文件??????43641??2016-11-23?14:45??databa
?????文件?????165959??2016-11-23?16:56??databa
?????文件???????3801??2016-11-23?14:45??databa
?????文件??????52964??2016-11-27?20:50??databa
?????文件???????1860??2016-11-26?21:20??databa
?????文件???????1705??2016-11-26?21:20??databa
?????文件??????66000??2016-11-27?19:54??databa
?????文件???????1379??2016-11-23?16:56??databa
?????文件????????354??2016-11-22?15:08??databa
?????文件???????2086??2016-11-13?13:33??databa
?????文件???????1642??2016-11-22?17:27??databa
?????文件???????1333??2016-11-13?16:27??databa
?????文件????????367??2016-11-22?11:47??databa
?????文件???????1129??2016-11-13?14:56??databa
?????文件????????645??2016-11-22?13:38??databa
?????文件???????2336??2016-11-22?14:05??databa
?????文件???????1636??2016-11-22?11:55??databa
?????文件???????3694??2016-11-22?12:29??databa
?????文件???????2163??2016-11-22?14:04??databa
............此處省略78個文件信息
評論
共有 條評論