📄 loginaction.java
字号:
package com.ghy.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.ghy.data.customer.Customer;
import com.ghy.data.customer.LoginForm;
import com.ghy.formToVo.LoginFormToVo;
import com.ghy.service.customer.CustomerServiceIfc;
public class LoginAction extends BaseAction {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
// TODO Auto-generated method stub
LoginForm loginForm = (LoginForm) form;
Customer customer = LoginFormToVo.loginConvert(loginForm);
CustomerServiceIfc customerServiceIfc = getCustomerServiceIfc();
boolean boo = true;
if (loginForm.getAction().equals("customer")) {
boo = customerServiceIfc.checkCustomer(customer.getName(), customer
.getPassword());
if (boo) {
HttpSession session = request.getSession();
customer = (Customer)customerServiceIfc.findCustomerByName(customer.getName()).get(0);
session.setAttribute("CurrentUser", customer);
response.sendRedirect(request.getContextPath()+"/booklist.do");
} else {
request.setAttribute("message", "用户名或者密码不对,请重新输入.");
return mapping.findForward("inexistence");
}
}
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -