logonform.java

来自「j2ee技术内幕源码包括了这本书的所有代码」· Java 代码 · 共 72 行

JAVA
72
字号
package unleashed.ch20.struts;import javax.servlet.http.HttpServletRequest;import org.apache.struts.action.*;public class LogonForm extends ActionForm {     /**     * The password.     */    private String password = null;    /**     * The username.     */    private String username = null;    /**     * Gets the password.     */    public String getPassword()     {	    return password;    }    /**     * Sets the password.     *     * @param password The new password     */    public void setPassword(String password)     {        this.password = password;    }    /**     * Gets the username.     */    public String getUsername()     {    	    return username;    }    /**     * Sets the username.     *     * @param username The new username     */    public void setUsername(String username)     {        this.username = username;    }    /**    * Validates username and password.    */       public ActionErrors validate(ActionMapping mapping,                                 HttpServletRequest request)     {        ActionErrors errors = new ActionErrors();        if ((username == null) || (username.length() < 1))            errors.add("username", new ActionError("error.username.required"));        if ((password == null) || (password.length() < 1))            errors.add("password", new ActionError("error.password.required"));        return errors;    }}

⌨️ 快捷键说明

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