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

📄 loginform.java

📁 一个关于STRUTS的学习资料
💻 JAVA
字号:
/*
 * LoginForm.java
 */
package com.oreilly.forms;


import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;


/**
 * Form bean for the Login main page.  There are two fields on this
 * form used for authentication
 * <ul>
 * <li>username - the username to login
 * <li>password - the password to authenticate
 * </ul>
 */
public final class LoginForm extends ActionForm  {
    private String userName = null;
    private String password = null;
    
    /**
     * Get the userName
     *@return String 
     */
    public String getUserName() {
    	return (userName);
    }

    /**
     * Set the userName.
     * @param userName 
     */
    public void setUserName(String newUserName) {
        userName = newUserName;
    }

    /**
     * Get the password
     *@return String 
     */
    public String getPassword() {
    	return (password);
    }

    /**
     * Set the password.
     * @param password 
     */
    public void setPassword(String newPassword) {
        password = newPassword;
    }


    /**
     * Reset all properties to their default values.
     *
     * @param mapping The mapping used to select this instance
     * @param request The servlet request we are processing
     */
    public void reset(ActionMapping mapping, HttpServletRequest request) {
        userName = null;
        password = null;
        
    }

    /**
     * Validate the properties that have been set from this HTTP request,
     * and return an <code>ActionErrors</code> object that encapsulates any
     * validation errors that have been found.  If no errors are found, return
     * <code>null</code> or an <code>ActionErrors</code> object with no
     * recorded error messages.
     *
     * @param mapping The mapping used to select this instance
     * @param request The servlet request we are processing
     */
    public ActionErrors validate(ActionMapping mapping,
                                 HttpServletRequest request) {
        ActionErrors errors = new ActionErrors();
        // For this form, only a username is required
	    if( userName == null || userName.length()==0 ){
            errors.add("userName",new ActionError("error.userName.required"));
        }
    	return (errors);
    }



}

⌨️ 快捷键说明

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