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

📄 stchangepswaction.java

📁 这是一个可以让学生选择自己喜欢的课题
💻 JAVA
字号:
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package com.yourcompany.struts.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

import allBeans.StZhiyuan;
import allBeans.Students;
import allDAOFactory.IFirstStudentTittleDAO;
import allDAOFactory.ILastStudentTittleDAO;
import allDAOFactory.IStudentDAO;
import allDAOFactory.ITittleDAO;

import com.yourcompany.struts.form.StchangepswForm;

/** 
 * MyEclipse Struts
 * Creation date: 07-30-2008
 * 
 * XDoclet definition:
 * @struts.action path="/stchangepsw" name="stchangepswForm" input="/Students/stchangepsw.jsp" scope="request" validate="true"
 */
public class StchangepswAction extends Action {
	/*
	 * Generated Methods
	 */

	/** 
	 * Method execute
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		StchangepswForm stchangepswForm = (StchangepswForm) form;// TODO Auto-generated method stub
		
		String stid=(String)request.getSession().getAttribute("userID"); //得到学生的ID
		if(stid==null)
			return mapping.findForward("tologinst");
		if(this.isCancelled(request))
		{
			String tm=(String)request.getSession().getAttribute("tm");  //得到学生系统当前的控制阶段
			if(tm.equals("1"))
			{
				IFirstStudentTittleDAO fstdao=new IFirstStudentTittleDAO();
				StZhiyuan stzhiyuanone=fstdao.fstget(stid,"1");
				StZhiyuan stzhiyuantwo=fstdao.fstget(stid,"2");
				StZhiyuan stzhiyuanthree=fstdao.fstget(stid,"3");
				request.setAttribute("stzhiyuanone", stzhiyuanone);
				request.setAttribute("stzhiyuantwo", stzhiyuantwo);
				request.setAttribute("stzhiyuanthree", stzhiyuanthree);
				return mapping.findForward("tostfirstmain");
			}
			else if(tm.equals("2"))
			{
				ILastStudentTittleDAO lstdao=new ILastStudentTittleDAO();
				StZhiyuan stzhiyuan=lstdao.lstgetzhiyuan(stid);
				request.setAttribute("stzhiyuan", stzhiyuan);
				if(stzhiyuan==null)
				{
					request.setAttribute("prior", "4");
				}
				else
				{
					ITittleDAO tidao=new ITittleDAO();
					String timemo=tidao.tiget(stzhiyuan.getTiid()).getTiMemo();
					request.setAttribute("timemo", timemo);
					request.setAttribute("prior", stzhiyuan.getPrior());
				}
				return mapping.findForward("tostsecondmain");
			}
			else if(tm.equals("3"))
			{
				ILastStudentTittleDAO lstdao=new ILastStudentTittleDAO();
				StZhiyuan stzhiyuan=lstdao.lstgetzhiyuan(stid);
				request.setAttribute("stzhiyuan", stzhiyuan);
				if(stzhiyuan!=null)
				{
				  ITittleDAO tidao=new ITittleDAO();
				  String timemo=tidao.tiget(stzhiyuan.getTiid()).getTiMemo();
				  request.setAttribute("timemo", timemo);
				}
				return mapping.findForward("tostlookmain");
			}
			else
			{
				return mapping.findForward("tologinst");
			}

		}
		
		ActionErrors errors=new ActionErrors();		
		Students student=new Students();
		IStudentDAO stdao=new IStudentDAO();
		student=stdao.stget(stid);
		if(student.getStPassword().equals(stchangepswForm.getPassword())) //如果输入的原始密码正确
		{
			String newpsw=stchangepswForm.getNewpassword();
			String repsw=stchangepswForm.getRepassword();
			if(newpsw.equals(repsw))  // 如果输入的新密码和确认密码相同
			{
				//执行更新操作
				student.setStPassword(newpsw);
				stdao.stupdate(student);
				String tm=(String)request.getSession().getAttribute("tm");
				if(tm.equals("1"))
				{
					IFirstStudentTittleDAO fstdao=new IFirstStudentTittleDAO();
					StZhiyuan stzhiyuanone=fstdao.fstget(stid,"1");
					StZhiyuan stzhiyuantwo=fstdao.fstget(stid,"2");
					StZhiyuan stzhiyuanthree=fstdao.fstget(stid,"3");
					request.setAttribute("stzhiyuanone", stzhiyuanone);
					request.setAttribute("stzhiyuantwo", stzhiyuantwo);
					request.setAttribute("stzhiyuanthree", stzhiyuanthree);
					return mapping.findForward("tostfirstmain");
				}
				else if(tm.equals("2"))
				{
					ILastStudentTittleDAO lstdao=new ILastStudentTittleDAO();
					StZhiyuan stzhiyuan=lstdao.lstgetzhiyuan(stid);
					request.setAttribute("stzhiyuan", stzhiyuan);
					if(stzhiyuan==null)
					{
						request.setAttribute("prior", "4");
					}
					else
					{
						ITittleDAO tidao=new ITittleDAO();
						String timemo=tidao.tiget(stzhiyuan.getTiid()).getTiMemo();
						request.setAttribute("timemo", timemo);
						request.setAttribute("prior", stzhiyuan.getPrior());
					}
					return mapping.findForward("tostsecondmain");
				}
				else if(tm.equals("3"))
				{
					ILastStudentTittleDAO lstdao=new ILastStudentTittleDAO();
					StZhiyuan stzhiyuan=lstdao.lstgetzhiyuan(stid);
					request.setAttribute("stzhiyuan", stzhiyuan);
					if(stzhiyuan!=null)
					{
					  ITittleDAO tidao=new ITittleDAO();
					  String timemo=tidao.tiget(stzhiyuan.getTiid()).getTiMemo();
					  request.setAttribute("timemo", timemo);
					}
					return mapping.findForward("tostlookmain");
				}
				else
				{
					student.setStPassword(stchangepswForm.getPassword());
					stdao.stupdate(student);
					return mapping.findForward("tologinst");
				}
				
			}
			else
			{
				errors.add("stchangepswoldnew",new ActionMessage("stchangepsw.oldnotnew"));
				this.addErrors(request, errors);
				return mapping.getInputForward();
			}
		}
		else
		{
				errors.add("stchangepswold",new ActionMessage("stchangepsw.old.wrong"));
				this.addErrors(request, errors);
				return mapping.getInputForward();
		}
	}
}

⌨️ 快捷键说明

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