loginaction.java

来自「ajax+struts最简单代码」· Java 代码 · 共 44 行

JAVA
44
字号
/*
 * Created on 2005-7-29
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package org.mstar.strutsajax.action;

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

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 org.mstar.strutsajax.ajax.UserLogic;
import org.mstar.strutsajax.form.LoginForm;

/**
 * @author matianyi
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class LoginAction extends Action {

	/* (non-Javadoc)
	 * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws Exception {
		if(validateUser((LoginForm)form)){
			return mapping.findForward("success");			
		} else {
			return mapping.findForward("failure");
		}		
	}
	
	private boolean validateUser(LoginForm form){
		UserLogic userLogic = new UserLogic();
		return userLogic.validate(form.getUsername(),form.getPassword());		
	}
}

⌨️ 快捷键说明

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