JavaBean skills

zhaozj2021-02-16  51

Although you can place the code in the script (Scriptlet), most Java code belongs to the components called Javabea, which are reusable. JavaBean is similar to the ActiveX control: they all provide common functions and can be reused.

The value of JavaBean is obtained through some properties, and you can access JavaBean settings through these properties. With one person, this person is a JavaBean, the name, ID number, and address of this person are its properties. In the JSP website, you basically make your website dynamize by playing "Connect The Beans". Suppose JavaBean is created first, the first thing you need to do is to tell the JSP page that it will use a "bean". You can use "" tag to do this:

"" Mark requires you to identify beans with the "ID" attribute. Here you offer a name that name to the rest of the JSP page. In addition to the "ID" attribute, you must also tell where to find bean, or what is its Java category name. This type of property provides a confirmation of the function of Bean, and some other methods can do this. The last required element is "scope" attribute. With the help of the "Scope" property, you can tell bean as a single page (default) [scope = "page"], for [Scope = "request"] request as a session [Scope = "session", or The entire application [scope = "application"] keeps the information. With the scope of the session, you can easily maintain items such as shopping carts on the JSP web page.

Once you have a Javabean, you can access its properties to customize it. To get attribute values, use "" tag. With this tag, you can specify the bean name that will be used (from the "ID" field of UseBean) and the properties you want to get the value. The actual value is placed in the output:

To change the JavaBean property, you must use the "" tag. For this tag, you need to identify beans and properties again to modify and provide additional new values. If naming is correct, these values ​​can be obtained directly from a submitted table: parameter get:

Can be obtained from a parameter, but you must directly name the properties and parameters:

Or use a name and value directly:

/>

转载请注明原文地址:https://www.9cbs.com/read-19516.html

New Post(0)