資源簡介
課程教學平臺設計源碼,java實現
<%
//設置編碼格式
request.setCharacterEncoding("GB18030");
//取到表單中用戶填寫的username,userpassword,userClass參數的值
String username = request.getParameter("username");
String userpassword = request.getParameter("userpassword");
System.out.println(username);
System.out.println(userpassword);
int userClass = Integer.parseInt(request.getParameter("userClass"));
System.out.println(userClass);
//判斷參數是否為空,或者是空字符串,如果是返回到index.jsp界面,如果符合標準跳到相應的管理后臺界面
if (username == null || username.trim().equals("")
|| userpassword == null || userpassword.trim().equals("")) {
request.getRequestDispatcher("index.jsp").forward(request,
response);
//response.sendRedirect("index.jsp");
} else {
//建立數據庫連接,判斷用戶名和密碼是否在數據庫user表中存在
Connection conn = DB1.getConn();
System.out.println(conn);
Statement stmt = DB1.createStmt(conn);
//sql語句,從user表中選擇出username和userpassword與用戶填入的一樣的數據
String sql = "select * from user where username = '" + username
+ "' and userpassword = '" + userpassword + "'";
ResultSet rs = DB1.executeQuery(stmt, sql);
System.out.println(conn);
if (rs.next()) {
//設置session,把用戶名添加到seesion屬性中
session.setAttribute("username", username);
request.setAttribute("username", username);
request.setAttribute("userClass", userClass);
//判斷登陸用戶是那種用戶類型,如果是1跳轉到學生頁面student.jsp,
//如果是2跳轉到教師頁面teacher.jsp,如果是3跳轉到管理員界面manager.jsp
int uc = rs.getInt(3);
if (uc == userClass) {
if (uc == 1) {
//request.getRequestDispatcher("student.jsp").forward(request, response);
response.sendRedirect("student.jsp");
} else if (uc == 2) {
//request.getRequestDispatcher("teacher.jsp").forward(request, response);
response.sendRedirect("teacher.jsp");
} else if (uc == 3) {
//request.getRequestDispatcher("manager.jsp").forward(request, response);
response.sendRedirect("manager.jsp");
}
}

代碼片段和文件信息
package?com.ComputerTrainingPlatform;
import?java.sql.ResultSet;
import?java.sql.SQLException;
public?class?ChoiceQuestion?{
private?int?id;
private?String?title;
private?String?option1;
private?String?option2;
private?String?option3;
private?String?option4;
private?String?answer;
private?int?difficulty;
public?int?getId()?{
return?id;
}
public?void?setId(int?id)?{
this.id?=?id;
}
public?String?gettitle()?{
return?title;
}
public?void?settitle(String?title)?{
this.title?=?title;
}
public?String?getOption1()?{
return?option1;
}
public?void?setOption1(String?option1)?{
this.option1?=?option1;
}
public?String?getOption2()?{
return?option2;
}
public?void?setOption2(String?option2)?{
this.option2?=?option2;
}
public?String?getOption3()?{
return?option3;
}
public?void?setOption3(String?option3)?{
this.option3?=?option3;
}
public?String?getOption4()?{
return?option4;
}
public?void?setOption4(String?option4)?{
this.option4?=?option4;
}
public?String?getAnswer()?{
return?answer;
}
public?void?setAnswer(String?answer)?{
this.answer?=?answer;
}
public?int?getDifficulty()?{
return?difficulty;
}
public?void?setDifficulty(int?difficulty)?{
this.difficulty?=?difficulty;
}
public?void?initFromRs(ResultSet?rs)?{
try?{
this.setId(rs.getInt(“id“));
this.settitle(rs.getString(“title“));
this.setOption1(rs.getString(“option1“));
this.setOption2(rs.getString(“option2“));
this.setOption3(rs.getString(“option3“));
this.setOption4(rs.getString(“option4“));
this.setAnswer(rs.getString(“answer“));
this.setDifficulty(rs.getInt(“difficulty“));
}?catch?(SQLException?e)?{
e.printStackTrace();
}
}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????600??2009-05-27?00:11??計算機基礎課程教學平臺+畢業設計+源代碼\ComputerTrainingPlatform\.classpath
?????文件????????346??2009-05-26?16:16??計算機基礎課程教學平臺+畢業設計+源代碼\ComputerTrainingPlatform\.myme
?????文件?????????66??2009-05-22?12:43??計算機基礎課程教學平臺+畢業設計+源代碼\ComputerTrainingPlatform\.myumldata
?????文件???????1430??2009-05-21?23:00??計算機基礎課程教學平臺+畢業設計+源代碼\ComputerTrainingPlatform\.project
?????文件????????406??2009-05-21?23:00??計算機基礎課程教學平臺+畢業設計+源代碼\ComputerTrainingPlatform\.settings\.jsdtscope
?????文件???????1040??2009-05-22?12:43??計算機基礎課程教學平臺+畢業設計+源代碼\ComputerTrainingPlatform\.settings\com.genuitec.eclipse.j2eedt.core.prefs
?????文件????????120??2009-05-22?12:43??計算機基礎課程教學平臺+畢業設計+源代碼\ComputerTrainingPlatform\.settings\com.genuitec.jboss.ide.eclipse.xdoclet.run.prefs
?????文件????????629??2009-05-22?01:17??計算機基礎課程教學平臺+畢業設計+源代碼\ComputerTrainingPlatform\.settings\org.eclipse.jdt.core.prefs
?????文件????????162??2009-05-22?12:43??計算機基礎課程教學平臺+畢業設計+源代碼\ComputerTrainingPlatform\.settings\org.eclipse.jdt.ui.prefs
?????文件?????????49??2009-05-21?23:00??計算機基礎課程教學平臺+畢業設計+源代碼\ComputerTrainingPlatform\.settings\org.eclipse.wst.jsdt.ui.superType.container
?????文件??????????6??2009-05-21?23:00??計算機基礎課程教學平臺+畢業設計+源代碼\ComputerTrainingPlatform\.settings\org.eclipse.wst.jsdt.ui.superType.name
?????文件????????299??2009-05-26?19:43??計算機基礎課程教學平臺+畢業設計+源代碼\ComputerTrainingPlatform\.settings\org.eclipse.wst.validation.prefs
?????文件???????7086??2009-05-25?22:30??計算機基礎課程教學平臺+畢業設計+源代碼\ComputerTrainingPlatform\sql\choicequestion.sql
?????文件???????2522??2009-05-26?02:00??計算機基礎課程教學平臺+畢業設計+源代碼\ComputerTrainingPlatform\sql\course.sql
?????文件????????129??2009-05-22?12:33??計算機基礎課程教學平臺+畢業設計+源代碼\ComputerTrainingPlatform\sql\message.sql
?????文件???????1496??2009-05-22?01:26??計算機基礎課程教學平臺+畢業設計+源代碼\ComputerTrainingPlatform\sql\news.sql
?????文件???????1427??2009-05-22?01:32??計算機基礎課程教學平臺+畢業設計+源代碼\ComputerTrainingPlatform\sql\notice.sql
?????文件????????136??2009-05-25?23:23??計算機基礎課程教學平臺+畢業設計+源代碼\ComputerTrainingPlatform\sql\score.sql
?????文件????????143??2009-05-22?11:18??計算機基礎課程教學平臺+畢業設計+源代碼\ComputerTrainingPlatform\sql\scoresimple.sql
?????文件???????9478??2009-05-25?23:22??計算機基礎課程教學平臺+畢業設計+源代碼\ComputerTrainingPlatform\sql\simplequestion.sql
?????文件????????142??2009-05-14?16:46??計算機基礎課程教學平臺+畢業設計+源代碼\ComputerTrainingPlatform\sql\sourcefile.sql
?????文件????????297??2009-05-26?17:22??計算機基礎課程教學平臺+畢業設計+源代碼\ComputerTrainingPlatform\sql\student.sql
?????文件?????????88??2009-05-08?14:39??計算機基礎課程教學平臺+畢業設計+源代碼\ComputerTrainingPlatform\sql\studentscore.sql
?????文件????????181??2009-05-26?17:21??計算機基礎課程教學平臺+畢業設計+源代碼\ComputerTrainingPlatform\sql\teacher.sql
?????文件????????239??2009-05-25?23:36??計算機基礎課程教學平臺+畢業設計+源代碼\ComputerTrainingPlatform\sql\testpaper.sql
?????文件????????266??2009-05-28?11:35??計算機基礎課程教學平臺+畢業設計+源代碼\ComputerTrainingPlatform\sql\user.sql
?????文件???????1816??2009-05-10?11:17??計算機基礎課程教學平臺+畢業設計+源代碼\ComputerTrainingPlatform\src\com\ComputerTrainingPlatform\ChoiceQuestion.java
?????文件???????1841??2009-05-26?02:02??計算機基礎課程教學平臺+畢業設計+源代碼\ComputerTrainingPlatform\src\com\ComputerTrainingPlatform\Course.java
?????文件???????2368??2009-05-24?07:13??計算機基礎課程教學平臺+畢業設計+源代碼\ComputerTrainingPlatform\src\com\ComputerTrainingPlatform\DB1.java
?????文件????????962??2009-05-22?12:35??計算機基礎課程教學平臺+畢業設計+源代碼\ComputerTrainingPlatform\src\com\ComputerTrainingPlatform\Message.java
............此處省略786個文件信息
- 上一篇:Java 設計的聊天程序-完整代碼
- 下一篇:Android 根據經緯度獲取地址
評論
共有 條評論