中国开发网: 论坛: 发牢骚: 贴子 248447
nostalgic: customerLoginAction
package com.service.customerlogin;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.Action;
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;

public class customerLoginAction extends Action {
public ActionForward execute(ActionMapping actionMapping,
ActionForm actionForm, HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) {

customerLoginForm customerloginForm = (customerLoginForm) actionForm;

customerDTO customerInfo = null;
customerDAO customerDao = null;
ActionForward forward = null;
ActionErrors errors = new ActionErrors();
HttpSession session = httpServletRequest.getSession();

try {
customerDao = customerDAOFactory.getDAO();
customerInfo = customerDao.getCustomer(customerloginForm.getLoginName());

if (customerInfo == null) {
errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(
"error.user.notfound"));
forward = actionMapping.getInputForward();
} else {
if (customerloginForm.getPassWord().trim().equals(
customerInfo.getPassWord())) {
session.setAttribute("customer", customerInfo);
forward = actionMapping.findForward("success");
} else {
errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(
"error.password.mismatch"));
forward = actionMapping.getInputForward();
}
}
} catch (Exception e) {
e.printStackTrace();
}
if (!errors.isEmpty()) {
saveErrors(httpServletRequest, errors);
}
return forward;
}
}

相关信息:


欢迎光临本社区,您还没有登录,不能发贴子。请在 这里登录