📄 getpasswordaction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package org.bestteam.web.struts.action;
import java.lang.reflect.InvocationTargetException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;
import org.apache.struts.actions.DispatchAction;
import org.bestteam.domain.UserInfo;
import org.bestteam.service.IsExistService;
/**
* MyEclipse Struts
* Creation date: 02-03-2007
*
* XDoclet definition:
* @struts.action path="/getPassword" name="getPasswordForm" input="/getPassword.jsp" parameter="method" scope="request" validate="true"
* @struts.action-forward name="success" path="/forget_password_2.jsp"
*/
public class GetPasswordAction extends DispatchAction {
private IsExistService isExistService;
public void setIsExistService(IsExistService isExistService) {
this.isExistService = isExistService;
}
public ActionForward firststep(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
ActionForward forward = mapping.findForward("failure");
try {
String username = (String) PropertyUtils.getProperty(form, "username");
UserInfo user = new UserInfo();
user.setUserName(username);
boolean state = isExistService.isExistUserInfo(user);
if (!state){
request.setAttribute("error", "此用户不存在,请重新填写!");
}
else {
forward = mapping.findForward("success");
request.getSession().setAttribute("username", username);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchMethodException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return forward;
}
public ActionForward secondStep(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
ActionForward forward = mapping.findForward("failure");
try {
String email = (String) PropertyUtils.getProperty(form, "email");
String username = request.getSession().getAttribute("username").toString();
UserInfo user = new UserInfo();
user.setUserName(username);
boolean state = isExistService.isExistUserInfo(user, email);
if (!state) {
request.setAttribute("error", "用户名和EMAIL不匹配,请重新输入!");
forward = mapping.findForward("failure");
}
else{
forward = mapping.findForward("success");
}
System.out.println(state);
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchMethodException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return forward;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -