那何为符合JavaBean标准的类呢? public class test { public String getString() { return "hello"; } }那你说这个类符合标准吗
这种基本问题自己看书好不好!!标准就是: public class test { private String value public String getValue() { return value; } public void setValue(String value) { this.value = value; } }
没背出,只能转一下贴: What is a JavaBean? A JavaBean is a collection of one or more Java classes, often bundled into a single JAR (Java Archive) file, that serves as a self-contained, reusable component. A JavaBean can be a discrete component used in building a user interface, or a non-UI component such as a data module or computation engine. At its simplest, a JavaBean is a public Java class that has a constructor with no parameters. JavaBeans usually have properties, methods, and events that follow certain naming conventions (also known as design patterns). Why build JavaBeans? Like other types of components, JavaBeans are reusable pieces of code that can be updated with minimal impact on the testing of the program they become a part of. JavaBeans have some unique advantages over other components, however: 1.They are pure Java, cross-platform components. 2.You can install them on the JBuilder component palette and use them in the construction of your program, or they can be used in other application builder tools for Java. 3.They can be deployed in JAR files.
public class test
{
public String getString()
{
return "hello";
}
}那你说这个类符合标准吗
public class test
{
private String value public String getValue()
{
return value;
}
public void setValue(String value)
{
this.value = value;
}
}
What is a JavaBean?
A JavaBean is a collection of one or more Java classes, often bundled into a
single JAR (Java Archive) file, that serves as a self-contained, reusable
component. A JavaBean can be a discrete component used in building a
user interface, or a non-UI component such as a data module or
computation engine.
At its simplest, a JavaBean is a public Java class that has a constructor with
no parameters. JavaBeans usually have properties, methods, and events
that follow certain naming conventions (also known as design patterns).
Why build JavaBeans?
Like other types of components, JavaBeans are reusable pieces of code that
can be updated with minimal impact on the testing of the program they
become a part of. JavaBeans have some unique advantages over other
components, however:
1.They are pure Java, cross-platform components.
2.You can install them on the JBuilder component palette and use them in
the construction of your program, or they can be used in other
application builder tools for Java.
3.They can be deployed in JAR files.
BEAN就是组件
<jsp:useBean id="count" class="count.counter" scope="request">
<jsp:setProperty name="CheckBean" property="*"/>
</jsp:useBean>
<%
String cont =count.getString();
%>还可以直接调用,通过counter count = new counter();
这两种是一样的,有区别吗
<%
counter count = new counter();
String cont =count.getString();
%>