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

📄 updatestudfamily.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:   UpdateStudFamily.java

package com.saintbo.servlet.student;

import com.saintbo.entity.student.TblStudentFamily;
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 javax.naming.InitialContext;
import javax.servlet.*;
import javax.servlet.http.HttpSession;

public class UpdateStudFamily extends MyExtendedServlet
{

    public UpdateStudFamily()
    {
    }

    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);
        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 fmlAddress = (String)reqInfo.get("FmlAddress");
        String fmlPostcode = (String)reqInfo.get("FmlPhone");
        String fmlPhone = (String)reqInfo.get("FmlPhone");
        String fatherName = (String)reqInfo.get("FatherName");
        String fatherComp = (String)reqInfo.get("FatherComp");
        String fatherCompPhone = (String)reqInfo.get("FatherCompPhone");
        String fatherCompPst = (String)reqInfo.get("FatherCompPst");
        String motherName = (String)reqInfo.get("MotherName");
        String motherComp = (String)reqInfo.get("MotherComp");
        String motherCompPhone = (String)reqInfo.get("MotherCompPhone");
        String motherCompPst = (String)reqInfo.get("MotherCompPst");
        String comments = (String)reqInfo.get("Comments");
        TblStudentFamily studentFamily = null;
        String errorMessage = "";
        boolean result = false;
        if(studentID != null && !studentID.trim().equals(""))
            try
            {
                InitialContext jndiContext = new InitialContext();
                StudentSessionLocalHome home = (StudentSessionLocalHome)jndiContext.lookup("StudentSessionLocal");
                StudentSessionLocal local = home.create();
                studentFamily = local.getStudentFamilyByStudentID(studentID);
                if(studentFamily != null)
                {
                    if(SysResource.getSysParamValByParamID(new Integer(130)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(130))))
                        studentFamily.setFmlAddress(fmlAddress);
                    if(SysResource.getSysParamValByParamID(new Integer(131)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(131))))
                        studentFamily.setFmlPostcode(fmlPostcode);
                    if(SysResource.getSysParamValByParamID(new Integer(132)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(132))))
                        studentFamily.setFmlPhone(fmlPhone);
                    if(SysResource.getSysParamValByParamID(new Integer(133)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(133))))
                        studentFamily.setFatherName(fatherName);
                    if(SysResource.getSysParamValByParamID(new Integer(134)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(134))))
                        studentFamily.setFatherComp(fatherComp);
                    if(SysResource.getSysParamValByParamID(new Integer(135)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(135))))
                        studentFamily.setFatherCompPhone(fatherCompPhone);
                    if(SysResource.getSysParamValByParamID(new Integer(136)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(136))))
                        studentFamily.setFatherCompPst(fatherCompPst);
                    if(SysResource.getSysParamValByParamID(new Integer(137)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(137))))
                        studentFamily.setMotherName(motherName);
                    if(SysResource.getSysParamValByParamID(new Integer(138)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(138))))
                        studentFamily.setMotherComp(motherComp);
                    if(SysResource.getSysParamValByParamID(new Integer(139)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(139))))
                        studentFamily.setMotherCompPhone(motherCompPhone);
                    if(SysResource.getSysParamValByParamID(new Integer(140)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(140))))
                        studentFamily.setMotherCompPst(motherCompPst);
                    if(SysResource.getSysParamValByParamID(new Integer(141)) != null && "1".equals(SysResource.getSysParamValByParamID(new Integer(141))))
                        studentFamily.setComments(comments);
                } else
                {
                    studentFamily = local.addStudentFamily(studentID, fmlAddress, fmlPostcode, fmlPhone, fatherName, fatherComp, fatherCompPhone, fatherCompPst, motherName, motherComp, motherCompPhone, motherCompPst, comments);
                }
                result = true;
                local.remove();
                jndiContext.close();
            }
            catch(Exception e)
            {
                errorMessage = "当增加该学生的家庭信息时出现错误.";
                result = false;
                e.printStackTrace();
            }
        else
            errorMessage = "传进来的学生学号不能为空.";
        if(result)
        {
            getServletContext().getRequestDispatcher("/student/Studentdetail.jsp").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 + -