?? loginaction.java
字號:
//Created by MyEclipse Struts// XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_4.0.1/xslt/JavaClass.xslpackage edu.sccp.qyj.struts.action;import java.util.Locale;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.apache.struts.action.Action;import org.apache.struts.action.ActionError;import org.apache.struts.action.ActionErrors;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionForward;import org.apache.struts.action.ActionMapping;import org.apache.struts.util.MessageResources;import edu.sccp.qyj.service.UserService;import edu.sccp.qyj.struts.form.LoginForm;/** * MyEclipse Struts * Creation date: 02-12-2007 * * XDoclet definition: * @struts.action path="/login" name="loginForm" input="/Login.jsp" scope="request" validate="true" * @struts.action-forward name="error" path="/error.jsp" */public class LoginAction extends Action { // --------------------------------------------------------- Instance Variables // --------------------------------------------------------- Methods /** * Method execute * @param mapping * @param form * @param request * @param response * @return ActionForward */ public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { /*//獲取用戶的Locale信息 Locale locale = this.getLocale(request); //獲取資源包 MessageResources message = this.getResources(request);*/ LoginForm loginForm = (LoginForm) form; // TODO Auto-generated method stub String userName = loginForm.getUserName(); ActionForward af = new ActionForward(); String userPassword = loginForm.getUserPassword(); ActionErrors errors = new ActionErrors(); UserService user = new UserService(); int i = user.checkUser(userName,userPassword); if(i==1){ af = mapping.findForward("ok"); }else if(i==2){ errors.add("username",new ActionError("login.jsp.error.username")); saveErrors(request,errors); af = new ActionForward(mapping.getInput()); }else if(i==3){ errors.add("userpassword",new ActionError("login.jsp.error.password")); saveErrors(request,errors); af = new ActionForward(mapping.getInput()); } return af; }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -