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

📄 helloform.java

📁 struts kick start书中代码
💻 JAVA
字号:
package ch03.hello;

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 Chapter 03 sample application, "Hello World!"
 *
 * @author Kevin Bedell and James Turner
 */
public final class HelloForm extends ActionForm {

    // --------------------------------------------------- Instance Variables

    /**
     * The person we want to say "Hello!" to
     */
    private String person = null;

    // ----------------------------------------------------------- Properties

    /**
     * Return the person to say "Hello!" to
     *
     * @return String person the person to say "Hello!" to
     */
    public String getPerson() {

        return (this.person);

    }

    /**
     * Set the person.
     *
     * @param person The person to say "Hello!" to
     */
    public void setPerson(String person) {

        this.person = person;

    }

    // --------------------------------------------------------- Public Methods

    /**
     * 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) {
        this.person = null;
    }

    /**
     * Validate the properties posted in this request. If validation errors are
     * found, return an <code>ActionErrors</code> object containing the errors.
     * If no validation errors occur, return <code>null</code> or an empty
     * <code>ActionErrors</code> object.
     *
     * @param mapping The current mapping (from struts-config.xml)
     * @param request The servlet request object
     */
    public ActionErrors validate(ActionMapping mapping,
                                 HttpServletRequest request) {

        ActionErrors errors = new ActionErrors();

        if ((person == null) || (person.length() < 1))
            errors.add("person", new ActionError("ch03.hello.no.person.error"));

        return errors;
    }
}

⌨️ 快捷键说明

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