⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 modifystudentinfo.java

📁 servlet做控制层示例
💻 JAVA
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   ModifyStudentInfo.java

package com.saintbo.servlet.student;

import com.saintbo.entity.student.TblStudent;
import com.saintbo.javabean.sys.SysResource;
import com.saintbo.javabean.sys.UserInfo;
import com.saintbo.servlet.MyExtendedServlet;
import com.saintbo.session.student.StudentSessionLocal;
import com.saintbo.session.student.StudentSessionLocalHome;
import com.saintbo.util.upload.RequestHashtable;
import com.saintbo.util.upload.UploadRequest;
import java.io.IOException;
import java.io.PrintStream;
import java.text.DateFormat;
import javax.naming.InitialContext;
import javax.servlet.*;
import javax.servlet.http.HttpSession;

public class ModifyStudentInfo extends MyExtendedServlet
{

    public ModifyStudentInfo()
    {
    }

    public void handle()
        throws IOException, ServletException
    {
        UserInfo userInfo = (UserInfo)session.getAttribute("USERINFO");
        int userAuthority = super.checkAuthority(userInfo, 1, 0);
        if(userAuthority != 1)
            return;
        reqInfo = UploadRequest.upload(req);
        TblStudent student = null;
        String studentID = "";
        if(userInfo.getUserType().equals(new Integer(1)))
            studentID = userInfo.getUserID();
        else
        if(userInfo.getUserType().equals(new Integer(3)))
            studentID = (String)reqInfo.get("StudentID");
        String name = (String)reqInfo.get("Name");
        String gender = (String)reqInfo.get("Gender");
        String strBirthday = (String)reqInfo.get("Birthday");
        String political = (String)reqInfo.get("Political");
        String nationality = (String)reqInfo.get("Nationality");
        String birthPlace = (String)reqInfo.get("BirthPlace");
        String comeFrom = (String)reqInfo.get("ComeFrom");
        String admitID = (String)reqInfo.get("AdmitID");
        String collegeID = (String)reqInfo.get("CollegeID");
        String deptID = (String)reqInfo.get("DeptID");
        String specType = (String)reqInfo.get("SpecType");
        String specID = (String)reqInfo.get("SpecialtyID");
        String specDir = (String)reqInfo.get("SpecDirection");
        String classID = (String)reqInfo.get("ClassID");
        String grade = (String)reqInfo.get("Grade");
        String studentType = (String)reqInfo.get("StudentType");
        String status = (String)reqInfo.get("Status");
        String strAdmitDate = (String)reqInfo.get("AdmitDate");
        String eduSystem = (String)reqInfo.get("EduSystem");
        Integer limit = new Integer((String)reqInfo.get("Litmit"));
        String graduateFrom = (String)reqInfo.get("GraduateFrom");
        String room = (String)reqInfo.get("Room");
        String email = (String)reqInfo.get("Email");
        String phone = (String)reqInfo.get("Phone");
        String identityID = (String)reqInfo.get("IdentityID");
        String gatIdentityID = (String)reqInfo.get("GATIdentityID");
        String health = (String)reqInfo.get("Health");
        String degreeStatus = (String)reqInfo.get("DegreeStatus");
        String comments = (String)reqInfo.get("Comments");
        boolean result = false;
        String errorMessage = "";
        if(studentID != null && !studentID.trim().equals(""))
            try
            {
                InitialContext jndiContext = new InitialContext();
                StudentSessionLocalHome home = (StudentSessionLocalHome)jndiContext.lookup("StudentSessionLocal");
                StudentSessionLocal local = home.create();
                student = local.getStudentByStudentID(studentID);
                if(student != null)
                {
                    if(SysResource.getSysParamValByParamID(new Integer(100)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(100))))
                        student.setName(name);
                    if(SysResource.getSysParamValByParamID(new Integer(101)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(101))))
                        student.setGender(gender);
                    if(SysResource.getSysParamValByParamID(new Integer(102)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(102))))
                    {
                        java.util.Date birthday = DateFormat.getDateInstance().parse(strBirthday);
                        student.setBirthday(birthday);
                    }
                    if(SysResource.getSysParamValByParamID(new Integer(103)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(103))))
                        student.setPolitical(political);
                    if(SysResource.getSysParamValByParamID(new Integer(104)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(104))))
                        student.setNationality(nationality);
                    if(SysResource.getSysParamValByParamID(new Integer(105)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(105))))
                        student.setBirthPlace(birthPlace);
                    if(SysResource.getSysParamValByParamID(new Integer(106)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(106))))
                        student.setComeFrom(comeFrom);
                    if(SysResource.getSysParamValByParamID(new Integer(107)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(107))))
                        student.setAdimtID(admitID);
                    if(SysResource.getSysParamValByParamID(new Integer(108)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(108))))
                        student.setCollegeID(collegeID);
                    if(SysResource.getSysParamValByParamID(new Integer(109)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(109))))
                        student.setDeptID(deptID);
                    if(SysResource.getSysParamValByParamID(new Integer(110)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(110))))
                        student.setSpecType(specType);
                    if(SysResource.getSysParamValByParamID(new Integer(111)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(111))))
                        student.setSpecialtyID(specID);
                    if(SysResource.getSysParamValByParamID(new Integer(112)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(112))))
                        student.setSpecDirection(specDir);
                    if(SysResource.getSysParamValByParamID(new Integer(113)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(113))))
                        student.setClassID(classID);
                    if(SysResource.getSysParamValByParamID(new Integer(114)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(114))))
                        student.setGrade(grade);
                    if(SysResource.getSysParamValByParamID(new Integer(115)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(115))))
                        student.setStudentType(studentType);
                    if(SysResource.getSysParamValByParamID(new Integer(116)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(116))))
                        student.setStatus(status);
                    if(SysResource.getSysParamValByParamID(new Integer(117)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(117))))
                    {
                        java.util.Date admitDate = DateFormat.getDateInstance().parse(strAdmitDate);
                        student.setAdmitDate(admitDate);
                    }
                    if(SysResource.getSysParamValByParamID(new Integer(118)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(118))))
                        student.setEduSystem(eduSystem);
                    if(SysResource.getSysParamValByParamID(new Integer(119)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(119))))
                        student.setLimit(limit);
                    if(SysResource.getSysParamValByParamID(new Integer(120)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(120))))
                        student.setGraduateFrom(graduateFrom);
                    if(SysResource.getSysParamValByParamID(new Integer(121)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(121))))
                        student.setRoom(room);
                    if(SysResource.getSysParamValByParamID(new Integer(122)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(122))))
                        student.setEmail(email);
                    if(SysResource.getSysParamValByParamID(new Integer(123)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(123))))
                        student.setPhone(phone);
                    if(SysResource.getSysParamValByParamID(new Integer(124)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(124))))
                        student.setIdentityID(identityID);
                    if(SysResource.getSysParamValByParamID(new Integer(125)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(125))))
                        student.setGatIdentityID(gatIdentityID);
                    if(SysResource.getSysParamValByParamID(new Integer(126)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(126))))
                        student.setHealth(health);
                    if(SysResource.getSysParamValByParamID(new Integer(127)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(127))))
                        student.setDegreeStatus(degreeStatus);
                    if(SysResource.getSysParamValByParamID(new Integer(129)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(129))))
                        student.setComments(comments);
                    result = true;
                } else
                {
                    errorMessage = "在数据库中找不到学号为' " + studentID + "' 的学生.";
                }
                local.remove();
                jndiContext.close();
            }
            catch(Exception e)
            {
                errorMessage = "当修改学生基本信息时出现错误.";
                System.out.println(errorMessage);
                e.printStackTrace();
            }
        else
            errorMessage = "传进来的学生学号不能为空.";
        if(result)
        {
            getServletContext().getRequestDispatcher("/student/studentdetail.jsp?StudentID=" + studentID).forward(req, res);
        } else
        {
            session.setAttribute("ERRORMESSAGE", errorMessage);
            getServletContext().getRequestDispatcher("/error/error.jsp").forward(req, res);
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -