JSP with javabean

xiaoxiao2021-03-06  83

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 the "" tag to do this: ". "" tag requires that you identify beans with the "ID" property. 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 category provides the ability to confirm the Bean, and some other methods can also 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 the "" 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.

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

New Post(0)