?? loginform.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 + -