📄 findpasswordaction.java
字号:
package com.longtime.wap.module.front.web.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionError;
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.springframework.web.struts.DispatchActionSupport;
import com.longtime.wap.model.UserInfo;
import com.longtime.wap.module.front.common.FrontConstant;
import com.longtime.wap.module.front.service.FrontService;
import com.longtime.wap.module.front.web.form.FindPasswordForm;
/**
* 找回密码请求处理
*
* @author bulc
* @date Nov 19, 2007
*/
public class FindPasswordAction extends DispatchActionSupport {
private static final Log LOGGER = LogFactory.getLog(
FindPasswordAction.class);
private FrontService frontService;
/**
* 注入服务对象
*
* @param frontService
* 服务对象
*/
public void setFrontService(FrontService frontService) {
this.frontService = frontService;
}
/**
* 找回密码请求处理
*
* @param mapping
* ActionMapping对象
* @param form
* ActionForm对象
* @param request
* HttpServletRequest对象
* @param response
* HttpServletResponse对象
* @return ActionForward对象
* @throws Exception
* 异常对象
*/
public ActionForward findPassword(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
FindPasswordForm passwordForm = (FindPasswordForm) form;
ActionErrors errors = new ActionErrors();
try {
UserInfo user = frontService.getUserByUsername(passwordForm
.getUsername());
if (null == user) {
errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(
"errors.userinexistence"));
} else {
if ("find".equalsIgnoreCase(passwordForm.getEditFlug())) {
passwordForm.setQuestion(user.getQuestion());
passwordForm.setEditFlug("answer");
} else if ("answer".equalsIgnoreCase(
passwordForm.getEditFlug())) {
if (user.getAnswer().equalsIgnoreCase(
passwordForm.getAnswer())) {
passwordForm.setPassword(user.getPassword());
passwordForm.setEditFlug("view");
} else {
errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(
"errors.answerinvalid"));
}
}
}
} catch (Exception ex) {
LOGGER.error(ex);
ex.printStackTrace();
}
saveErrors(request, errors);
return mapping.findForward("findPassowrd");
}
/**
* 找回密码请求处理
*
* @param mapping
* ActionMapping对象
* @param form
* ActionForm对象
* @param request
* HttpServletRequest对象
* @param response
* HttpServletResponse对象
* @return ActionForward对象
* @throws Exception
* 异常对象
*/
public ActionForward forwardFindPassword(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
FindPasswordForm passwordForm = new FindPasswordForm();
passwordForm.setEditFlug("find");
request.setAttribute(FrontConstant.PASSWORD_FORM, passwordForm);
return mapping.findForward("findPassowrd");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -