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

📄 loginform.java

📁 利用当前管理信息系统科学的、实用的理论
💻 JAVA
字号:
package com.haizi.struts.action;

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;

public class LoginForm extends ActionForm {
	
	private String name;
	private String password;
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}	

	public LoginForm() {
		super();
		resetFields();	
	}
	
	protected void resetFields() {
		this.name = null;
		this.password = null;
	}
	
	public void reset(ActionMapping mapping, HttpServletRequest req) {
		
		super.reset(mapping, req);
	}

	public ActionErrors validate(ActionMapping mapping, HttpServletRequest req) {
		ActionErrors errors = new ActionErrors();
		if(getName() == null || getName().length() < 1) {
		      errors.add( ActionErrors.GLOBAL_ERROR,
		                  new ActionError("global.required", "name" ));
		    }
		    if(getPassword() == null || getPassword().length() < 1) {
		      errors.add( ActionErrors.GLOBAL_ERROR,
		                  new ActionError("global.required", "password" ));
		    }
		    return errors;
	}
	}

	

⌨️ 快捷键说明

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