📄 selectsomethingaction.java
字号:
request.setAttribute("ls", ls);
return mapping.findForward("updateStu");
}
public ActionForward addScore(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws SQLException {
if (request.getSession().getAttribute("port") == null
|| request.getSession().getAttribute("teacher") == null) {
return mapping.findForward("teacher_login");
}
int teacher_id = Integer.parseInt(request.getParameter("teacher_id"));
List ls = ServiceUtil.getSelectSomethingService().getClassInfo(
teacher_id);
request.setAttribute("ls", ls);
return mapping.findForward("addSco");
}
public ActionForward selectSubject(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws SQLException {
if (request.getSession().getAttribute("port") == null
|| request.getSession().getAttribute("teacher") == null) {
return mapping.findForward("teacher_login");
}
int year_id = Integer.parseInt(request.getParameter("year_id"));
int class_id = Integer.parseInt(request.getParameter("class_id"));
int port_id = Integer.parseInt(request.getParameter("port_id"));
String stu_number = StringUtil.toUtf8Code(request
.getParameter("stu_number"));
String stu_name = StringUtil.toUtf8Code(request
.getParameter("stu_name"));
String stu_sex = StringUtil.toUtf8Code(request.getParameter("stu_sex"));
String str1 = "1";
String str2 = "0";
StudentUser su = new StudentUser();
su.setStu_number(stu_number);
su.setStu_name(stu_name);
su.setStu_sex(stu_sex);
HashMap hm = ServiceUtil.getSelectSomethingService().getScoreInfo(
stu_number, year_id, class_id, port_id);
if (hm.get("state") == null) {
request.setAttribute("textStr", str1);
} else if ((Integer) hm.get("state") == 1) {
request.setAttribute("textStr", str2);
}
List ls = ServiceUtil.getSelectSomethingService().getSubjectInfo(
year_id, class_id, port_id);
if (ls.size() > 0) {
request.setAttribute("active", "1");
} else {
request.setAttribute("active", "0");
}
request.setAttribute("ls", ls);
request.setAttribute("su", su);
return mapping.findForward("subjectList");
}
public ActionForward selectTeacher(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws SQLException {
if (request.getSession().getAttribute("port") == null
|| request.getSession().getAttribute("teacher") == null) {
return mapping.findForward("teacher_login");
}
int teacher_id = Integer.parseInt(request.getParameter("teacher_id"));
HashMap hm = ServiceUtil.getSelectSomethingService().getTeacherInfo(
teacher_id);
request.setAttribute("teacherList", hm);
return mapping.findForward("selectTeacher");
}
public ActionForward selectTeacherForUpdate(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws SQLException {
if (request.getSession().getAttribute("port") == null
|| request.getSession().getAttribute("teacher") == null) {
return mapping.findForward("teacher_login");
}
int teacher_id = Integer.parseInt(request.getParameter("teacher_id"));
HashMap hm = ServiceUtil.getSelectSomethingService().getTeacherInfo(
teacher_id);
request.setAttribute("teacherList", hm);
return mapping.findForward("selectTeacherForUpdate");
}
public ActionForward selectTeacherUser(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws SQLException {
if (request.getSession().getAttribute("port") == null
|| request.getSession().getAttribute("teacher") == null) {
return mapping.findForward("teacher_login");
}
int teacher_id = Integer.parseInt(request.getParameter("teacher_id"));
HashMap hm = ServiceUtil.getSelectSomethingService().getTeacherInfo(
teacher_id);
request.setAttribute("teacherList", hm);
return mapping.findForward("selectTeacherUser");
}
public ActionForward selectStudentUser(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws SQLException {
if (request.getSession().getAttribute("user") == null) {
return mapping.findForward("student_login");
}
int stu_id = Integer.parseInt(request.getParameter("stu_id"));
HashMap hm = ServiceUtil.getSelectSomethingService()
.getStudentMessageInfo(stu_id);
request.setAttribute("studentList", hm);
return mapping.findForward("selectStudentUser");
}
public ActionForward selectCondition(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws SQLException {
if (request.getSession().getAttribute("user") == null) {
return mapping.findForward("student_login");
}
int class_id = Integer.parseInt(request.getParameter("class_id"));
int port_id = Integer.parseInt(request.getParameter("port_id"));
HashMap hm1 = ServiceUtil.getSelectSomethingService()
.getClass(class_id);
HashMap hm2 = ServiceUtil.getSelectSomethingService().getPort(port_id);
List ls = ServiceUtil.getSelectSomethingService().getYearsInfo();
request.setAttribute("classList", hm1);
request.setAttribute("portList", hm2);
request.setAttribute("yearList", ls);
return mapping.findForward("selectCondition");
}
public ActionForward selectScore(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws SQLException {
if (request.getSession().getAttribute("user") == null) {
return mapping.findForward("student_login");
}
CreateCSVFile createCSVFile = new CreateCSVFile();
createCSVFile.setData("Name");
createCSVFile.setData("Number");
createCSVFile.setData("Sex");
createCSVFile.setData("Subject");
createCSVFile.setData("Score");
createCSVFile.writeLine();
String score_number = StringUtil.toUtf8Code(request
.getParameter("stu_number"));
int year_id = Integer.parseInt(request.getParameter("year_id"));
int class_id = Integer.parseInt(request.getParameter("class_id"));
int port_id = Integer.parseInt(request.getParameter("port_id"));
List ls = ServiceUtil.getSelectSomethingService().getScore(
score_number, year_id, class_id, port_id);
if (ls.size() > 0) {
request.setAttribute("active", "1");
} else {
request.setAttribute("active", "0");
}
for (int i = 0; i < ls.size(); i++) {
HashMap hm = (HashMap) ls.get(i);
createCSVFile.setData(hm.get("score_name"));
createCSVFile.setData("'"+hm.get("score_number"));
createCSVFile.setData(hm.get("score_sex"));
createCSVFile.setData(hm.get("score_subject"));
createCSVFile.setData(hm.get("score_score"));
createCSVFile.writeLine();
}
createCSVFile.close();
request.getSession().setAttribute("score_list", ls);
request.setAttribute("scoreList", ls);
return mapping.findForward("selectScore");
}
public ActionForward downloadCsv(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws SQLException, IOException {
if (request.getSession().getAttribute("user") == null) {
return mapping.findForward("student_login");
}
PrintWriter pw = null;
response.setContentType("application/octet-stream;charset=GBK");
response.setHeader("Content-Disposition",
"attachment; filename=\"StudentScore.csv\"");
List scoreList = (List) request.getSession().getAttribute("score_list");
String strHead = "Name,Number,Sex,Subject,Score";
pw = response.getWriter();
pw.println(strHead);
for (int i = 0; i < scoreList.size(); i++) {
HashMap hm = (HashMap) scoreList.get(i);
String name = String.valueOf(hm.get("score_name"));
String number = String.valueOf(hm.get("score_number"));
String sex = String.valueOf(hm.get("score_sex"));
String subject = String.valueOf(hm.get("score_subject"));
String score = String.valueOf(hm.get("score_score"));
String strLine = "\"" + name + "\",\"" + "'"+number + "\",\"" + sex
+ "\",\"" + subject + "\",\"" + score + "\"";
pw.println(strLine);
}
pw.flush();
pw.close();
return null;
}
public ActionForward selectStudentInfo(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws SQLException {
if (request.getSession().getAttribute("user") == null) {
return mapping.findForward("student_login");
}
int stu_id = Integer.parseInt(request.getParameter("stu_id"));
int class_id = Integer.parseInt(request.getParameter("class_id"));
int port_id = Integer.parseInt(request.getParameter("port_id"));
HashMap hm1 = ServiceUtil.getSelectSomethingService()
.getClass(class_id);
HashMap hm2 = ServiceUtil.getSelectSomethingService().getPort(port_id);
HashMap hm3 = ServiceUtil.getSelectSomethingService()
.getStudentMessageInfo(stu_id);
request.setAttribute("classList", hm1);
request.setAttribute("portList", hm2);
request.setAttribute("studentList", hm3);
return mapping.findForward("selectStudentInfo");
}
public ActionForward selectStuForUpdate(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws SQLException {
if (request.getSession().getAttribute("user") == null) {
return mapping.findForward("student_login");
}
int stu_id = Integer.parseInt(request.getParameter("stu_id"));
HashMap hm = ServiceUtil.getSelectSomethingService()
.getStudentMessageInfo(stu_id);
request.setAttribute("studentList", hm);
return mapping.findForward("selectStuForUpdate");
}
public ActionForward selectDepartment(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws SQLException {
if (request.getSession().getAttribute("admin") == null) {
return mapping.findForward("admin_login");
}
List ls = ServiceUtil.getSelectSomethingService().getPortInfo();
request.setAttribute("dpList", ls);
return mapping.findForward("selectDp");
}
public ActionForward selectYear(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws SQLException {
if (request.getSession().getAttribute("admin") == null) {
return mapping.findForward("admin_login");
}
List ls = ServiceUtil.getSelectSomethingService().getYearsInfo();
if (ls.size() > 0) {
request.setAttribute("active", "1");
} else {
request.setAttribute("active", "0");
}
request.setAttribute("yearList", ls);
return mapping.findForward("selectYear");
}
public ActionForward checkDp(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws SQLException {
if (request.getSession().getAttribute("admin") == null) {
return mapping.findForward("admin_login");
}
List ls = ServiceUtil.getSelectSomethingService().getPortInfo();
request.setAttribute("dpList", ls);
return mapping.findForward("checkDp");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -