thchangepswaction.java
来自「这是一个可以让学生选择自己喜欢的课题」· Java 代码 · 共 79 行
JAVA
79 行
/*
* 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.Teachers;
import allDAOFactory.ITeacherDAO;
import com.yourcompany.struts.form.ThchangepswForm;
/**
* MyEclipse Struts
* Creation date: 08-04-2008
*
* XDoclet definition:
* @struts.action path="/thchangepsw" name="thchangepswForm" input="/Teachers/thchangepsw.jsp" scope="request" validate="true"
*/
public class ThchangepswAction 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) {
ThchangepswForm thchangepswForm = (ThchangepswForm) form;// TODO Auto-generated method stub
if(this.isCancelled(request))
{
return mapping.findForward("toteachermain");
}
ActionErrors errors=new ActionErrors();
String thid=(String)request.getSession().getAttribute("userID");
Teachers th=new Teachers();
ITeacherDAO thdao=new ITeacherDAO();
th=thdao.thget(thid);
if(th.getThPassword().equals(thchangepswForm.getPassword())) //如果输入的原始密码正确
{
String newpsw=thchangepswForm.getNewpassword();
String repsw=thchangepswForm.getRepassword();
if(newpsw.equals(repsw)) // 如果输入的新密码和确认密码相同
{
//执行更新操作
th.setThPassword(newpsw);
thdao.thupdate(th);
return mapping.findForward("toteachermain");
}
else
{
errors.add("thchangepswoldnew",new ActionMessage("thchangepsw.oldnotnew"));
this.addErrors(request, errors);
return mapping.getInputForward();
}
}
else
{
errors.add("thchangepswold",new ActionMessage("thchangepsw.old.wrong"));
this.addErrors(request, errors);
return mapping.getInputForward();
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?