Bean样例:
/*
 * SimpleBean.java
 *
 * Created on 2006年9月20日, 下午5:51
 */
package org.openthoughts.beans;
import 
Java.io.Serializable;
import 
Java.util.HashMap;
/**
 * @author Administrator
 */
public class SimpleBean implements Serializable {    
    private String userName;    
    private String password;    
    public SimpleBean() {        
    }    
    public String getUserName() {
        return userName;
    }    
    public void setUserName(String userName) {
        this.userName = userName;
    }
    public String getPassword() {
        return password;
    }    
    public void setPassword(String password) {
        this.password = password;
    }    
    //错误信息
    public HashMap getAllErrors() {
        return new HashMap();
    }
}
ThreadLocal实现:
/*
 * Form2BeanUtil.java
 *
 * Created on 2006年9月20日, 下午4:51
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
package org.openthoughts.util;
/**
 * Hold formbean for appropriate thread via ThreadLocal.
 *
 * @author <a href="guangquanzhang@gmail.com">javafuns</a>
 */
public class Form2BeanUtil {    
    private static final ThreadLocal container = new ThreadLocal();    
    /**
     * Put the form bean to ThreadLocal.
     */
    public static void put(Object object) {
        container.set(object);
    }    
    /**
     * Get the current thread's form bean.
     */
    public static Object get() {
        return container.get();
    }
}
PS: 类似的方式在很多框架都有实现,比如struts的formbean