⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 loginaction.java

📁 在学习期间做的小型的图书选购项目 仅仅适合研究使用
💻 JAVA
字号:
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package com.knt.action;

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.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.knt.actionform.LoginActionForm;
import com.knt.dao.UserServiceImpl;
import com.knt.interfaces.UserService;
import com.knt.pojo.Customer;

/** 
 * MyEclipse Struts
 * Creation date: 04-09-2009
 * 
 * XDoclet definition:
 * @struts.action path="/loginAction" name="loginaActionForm" input="/login.jsp" parameter="method" scope="request" validate="true"
 * @struts.action-forward name="index" path="/index.jsp"
 * @struts.action-forward name="loginerror" path="/loginerror.jsp"
 */
public class LoginAction extends Action {
	/*
	 * Generated Methods
	 */

	/** 
	 * Method execute
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		LoginActionForm loginaActionForm = (LoginActionForm) form;
		String name = loginaActionForm.getName();
		String password = loginaActionForm.getPassword();
		UserService userService = new UserServiceImpl();
		if(userService.checkAccount(name, password)){
			Customer customer = new Customer();
			customer.setName(name);
			HttpSession session = request.getSession();
			session.setAttribute("user",userService.loadCustomer(name));			
			return mapping.findForward("index");
		}
		request.setAttribute("message","用户名或密码错误");
		return mapping.findForward("loginerror");
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -