package com.billscan.action;
import java.lang.reflect.InvocationTargetException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.billscan.form.UserForm;
import com.billscan.entity.*;
import com.billscan.dao.*;
public class LoginAction extends Action{
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
// TODO Auto-generated method stub
ActionForward forward=null;
UserForm userF=(UserForm)form;
UserEntity entity=new UserEntity();
try {
BeanUtils.copyProperties(entity,userF);
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
userDao dao=new userDao();
boolean b=dao.isRigth(entity);
if(b){
forward=mapping.findForward("success");
}else{
forward=mapping.findForward("fail");
}
return forward;
}
}