The JavaBean specification introduces the concept of "software components" into the Java programming field. Javabean is a software component model that describes java. Its main purpose is to achieveCode.
Javabean is a Java class. Compared with a common Java class, it must comply with the following rules:
1. Implementation interface Java. io. serializable; Java "Object serialization" 2. JavaBean class provides a non-parameter constructor 3. attributes in JavaBean should be declared as private4 and attributes in JavaBean should be accessed through setxxx () and the getxxx () method. 5. The access attribute method in the JavaBean must be declared as public.
Attributes of JavaBean
Common three properties: simple attributes are usually a single-value attribute with a bunch of get/set methods. Boolean attribute: the setting method of a Boolean attribute is the same as that of a simple attribute. The method for getting a value is usually replaced by isxxx () instead of getxxx (). Index attribute: indicates a set attribute, such as an array and a list. Generally, two set methods and two get methods are provided for the index attribute. You can read and set the entire attribute or a single element value.
Java-related action tags: <JSP: usebean>, <JSP: setproperty>, and <JSP: getproperty>
Scope of application of JavaBean
The page range is limited to the current page and cannot be shared among multiple pages. The request range is limited to one request, which may span multiple pages and involve multiple Web components. The session range is limited to one session, it can contain multiple requests. The application has the largest range, which is the whole application and contains all sessions.