loginaction.java
来自「用STRUTS ,HIBERNATE, SPRING 三种框架整合做的实战项目」· Java 代码 · 共 45 行
JAVA
45 行
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 + =
减小字号Ctrl + -
显示快捷键?