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

📄 loginactionform.java

📁 java中如何对Struts技术使用的示范代码!代码详细。
💻 JAVA
字号:

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

public class LogInActionForm extends ActionForm {

	private String userName;
	private String userPassword;

	public ActionErrors validate(ActionMapping mapping,	HttpServletRequest request){
		
		ActionErrors actionErrors=new ActionErrors();
		
		if(userName==null || userName.equals(""))
		{
			actionErrors.add(ActionErrors.GLOBAL_MESSAGE,new ActionMessage("用户名不能为空"));
		}
		
		else if(userName.length()>20)
		{
			actionErrors.add(ActionErrors.GLOBAL_MESSAGE,new ActionMessage("用户名长度不能大于20"));
		}
		
		if(userPassword==null || userPassword.equals(""))
		{
			actionErrors.add(ActionErrors.GLOBAL_MESSAGE,new ActionMessage("用户密码不能为空"));
		}
		
		else if(userPassword.length()>20)
		{
			actionErrors.add(ActionErrors.GLOBAL_MESSAGE,new ActionMessage("用户密码长度不能大于20"));
		}
		
		return actionErrors;
	}

	public void reset(ActionMapping mapping, HttpServletRequest request) {

	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getUserPassword() {
		return userPassword;
	}

	public void setUserPassword(String userPasswrord) {
		this.userPassword = userPasswrord;
	}
	
}

⌨️ 快捷键说明

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