JavaBean and JSP standard action __ Large data

Source: Internet
Author: User
I. JavaBean
1. Understanding: Java classes that can be reused
2. Classification
1 beans that encapsulate data (equivalent to entity classes)
2 encapsulation of the business bean (generally is the implementation of additions and deletions to check)
3. Note:
1 The bean that encapsulates the data generally satisfies the following two conditions
1.implements Serializable: Implementing the Serialization interface
2. Have a parameterless public constructor: easy to use with JSP actions
4. Two ways to create and use:
1) Use Scriptlet code to implement.
2 JSP standard action to achieve.


Two. Standard action
1. Understanding: Label to create and use JavaBean, which is conducive to the development of JSP Application Division, improve the maintainability of JSP applications
2. Categories:
1) Usebean: Creating and using Beans
2) SetProperty: Assigning values to the Bean's properties
3) GetProperty: Remove the value of the Bean's properties
4) Forward: Jump, equivalent forwarding
5) include: dynamic inclusion
3. Usage:
1) Usebean
Example:
<jsp:usebean id= "Emp1" class= "Com.entity.Employee" scope= "Session"/>
Attention:
1 The corresponding class must have a parameterless public constructor
2 If there is no emp1 in the corresponding scope, the object is created, otherwise the object is obtained.


2) SetProperty
Example:
<jsp:setproperty name= "Emp1" property= "EmpNo" value= "001"/>
Attention:
1 at this point, the corresponding class must have: Setempno () method
2) value can only assign static value, param may be dynamically assigned value;
3) value and Param cannot be used simultaneously
4 when the property attribute value is "*", the value of all parameters in the request requests are assigned to the bean in the same name as the parameter.


3) GetProperty
Example:
<jsp:getproperty name= "Emp1" property= "EmpNo"/>
Attention:
1 at this point, the corresponding class must have: Getempno () method




4) Forward
Format:
<jsp:forward page= "url"/>
Example: <jsp:forward page= "index2.jsp"/>
Note: the equivalent of forwarding, and bring return


5) include
Format: <jsp:include page= "Weburl" flush= "true"/>
Attention:
1 Action is dynamic inclusion
2 The difference between <jsp:include> and <% @include >:
Instructions are static include: merge first, then compile
Actions are dynamic include: Compile separately, then merge after compilation







Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.