1, what is JavaBean
JavaBean is an important component in Java that can be cross-platform, and it is a component architecture. JavaBean in the server side of the application shows a strong vitality, in the JSP program commonly used to encapsulate business logic, database operations.
JavaBean is actually a Java class, and this class can be reused. From the JavaBean function can be divided into: packaging data and encapsulation business.
JavaBean is a public class and provides an parameterless, publicly constructed method. property is private. Getter and setter methods that have public access properties.
1.1, a javabean of encapsulated data typically corresponds to a table (or view) within the database, and the JavaBean property corresponds to the property one by one of the field in the table (or view). Relative to the javabean of a encapsulated data, there is usually a javabean that encapsulates the business logic and business operations of the class.
2. The object-oriented thought of JavaBean
When a method has a lot of parameters, one argument is very troublesome. From an object-oriented perspective, when a business recovery operation database table, it is only possible to pass to the method a corresponding instance object to the table. The object contains the values of each field in the table, and there is only one argument, and the passed argument is the JavaBean object (the Java class object).
3, JSP standard action
The JSP standard action executes when the browser requests the page, and the JSP standard action can use existing JavaBean components and attributes, and transfer the user request to another page.
The JSP standard action uses <jsp:> as the prefix, the attributes in the JSP standard action are case-sensitive, and the values in the attribute must be enclosed in quotation marks.
The benefits of using JSP standard actions are that they can be easily developed and reflected in the reuse of code. can be convenient for artists to beautify the page, in the JSP reduced a lot of Java code. Simplifies the process of acquiring and encapsulating data.
3.1, Jsp:usebean action is used to load a javabean that will be used in JSP pages. The syntax is as follows:
<jsp:usebean id= "name" class= "Package.class" scope= "Scope"/>
The ID is used to create the JavaBean reference name and to create the name of the object. Class is used to specify JavaBean classes and to create types of objects. Scope is used to specify the range of JavaBean, the scope of the object, and the default setting is page.