📄 thshowaction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.onlinestudy.action.teacher;
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import com.onlinestudy.domain.Classes;
import com.onlinestudy.domain.Students;
import com.onlinestudy.service.StudentService;
public class ThshowAction extends DispatchAction {
StudentService studentService;
//显示增加学生页面
public ActionForward showAddStudents(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
List list = studentService.selectClasses();
request.setAttribute("list", list);
request.getRequestDispatcher("addstudent.jsp").forward(request, response);
return null;
}
//显示班级管理页面
public ActionForward showAddclasses(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
List list = studentService.selectClasses();
request.setAttribute("list", list);
request.getRequestDispatcher("class_list.jsp").forward(request, response);
return null;
}
//显示修改学生页面
public ActionForward showUdateStudents(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
int id = Integer.parseInt(request.getParameter("id"));
Students students = studentService.selectStudentById(id);
List list = studentService.selectClasses();
request.setAttribute("list", list);
request.setAttribute("students", students);
request.getRequestDispatcher("updatestudent.jsp").forward(request, response);
return null;
}
//分页查询学生列表
public ActionForward showStudentList(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception{
int currentPage = 1;
currentPage = Integer.parseInt(request.getParameter("nextpage"));
int totalStudents = studentService.selectAllStudent("select id from Students");
int length = 10; //读取数据记录数
String hql = "from Students";
int totalPages = (totalStudents-1)/length+1;
if(currentPage < 1){
currentPage = 1;
}
if(currentPage > totalPages){
currentPage = totalPages;
}
int offset = (currentPage-1)*length; //开始取数据的下标
List list = studentService.selectStudentForPage(hql, offset, length);
request.setAttribute("totalStudents", Integer.toString(totalStudents));
request.setAttribute("totalPages", Integer.toString(totalPages));
request.setAttribute("currentPage", Integer.toString(currentPage));
request.setAttribute("list", list);
request.getRequestDispatcher("student_list.jsp").forward(request, response);
return null;
}
//查询未审核的学生
public ActionForward showNewStudentList(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception{
int currentPage = 1;
currentPage = Integer.parseInt(request.getParameter("nextpage"));
int totalStudents = studentService.selectAllStudent("select id from Students where ispass!='是'");
int length = 10; //读取数据记录数
String hql = "from Students where ispass!='是'";
int totalPages = (totalStudents-1)/length+1;
if(currentPage < 1){
currentPage = 1;
}
if(currentPage > totalPages){
currentPage = totalPages;
}
int offset = (currentPage-1)*length; //开始取数据的下标
List list = studentService.selectStudentForPage(hql, offset, length);
request.setAttribute("totalStudents", Integer.toString(totalStudents));
request.setAttribute("totalPages", Integer.toString(totalPages));
request.setAttribute("currentPage", Integer.toString(currentPage));
request.setAttribute("list", list);
request.getRequestDispatcher("newstudent_list.jsp").forward(request, response);
return null;
}
public void setStudentService(StudentService studentService) {
this.studentService = studentService;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -