JAVABean与普通的Class有什么区别?

tonglife 2003-07-09 10:20:09
JAVABean与普通的Class有什么区别?
普通的Class可以当作JAVABean在JSP里引用吗?跟JAVABEAN引用有区别吗?

我是新手,谢谢啦!
...全文
120 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
pleonheart 2003-07-09
  • 打赏
  • 举报
回复
楼上你在干嘛?
gks_cn 2003-07-09
  • 打赏
  • 举报
回复
不管是什么都可以用new 创建
<%
sdk.Tools mytool=new sdk.Tools();
try{
sun.jdbc.rowset.CachedRowSet rs=mytool.executeQuery("select * from test");
while (rs.next()){
out.println(rs.getString(1));
out.println("+"+sdk.Tools.toGBKString(rs.getString(2)));
out.println("<br>");
}
}
catch(Exception e){
out.println(e.getMessage());
}
%>
Rayy 2003-07-09
  • 打赏
  • 举报
回复
To:moumouren(某某人)
请问为申麽"建议还是不要使用javabean"
不是要分开显示和逻辑吗?
wltsui 2003-07-09
  • 打赏
  • 举报
回复
学习
rosen 2003-07-09
  • 打赏
  • 举报
回复
差不多
birdofparadise001 2003-07-09
  • 打赏
  • 举报
回复
javabean 类似于普通class里得功能函数。
Tongates 2003-07-09
  • 打赏
  • 举报
回复
普通的Class可以当作JAVABean在JSP里引用,没有什么特别的地方
我支持楼上的说法,bean只不过是特殊点的,功能狭隘的class罢了
ukyer 2003-07-09
  • 打赏
  • 举报
回复
一般写java应用程序都有main函数,javabean 可以没有,它只是一个组件,实现某一功能的零件 :)
unsalted 2003-07-09
  • 打赏
  • 举报
回复
没有什么区别,一样用。
moumouren 2003-07-09
  • 打赏
  • 举报
回复
JAVABean比普通的class,规矩更多些,使用更麻烦些

所以建议还是不要使用javabean
kingdomzhf 2003-07-09
  • 打赏
  • 举报
回复
Basic Bean Concepts
JavaBeans, regardless of their functionality, are defined by the following features.
· Introspection —Beans support introspection, which allows a builder tool to analyze how Beans work. They adhere to specific rules called design patterns for naming Bean features. Each Bean has a related Bean information class, which provides property, method, and event information about the Bean itself. Each Bean information class implements a BeanInfo interface, which explicitly lists the Bean features that are to be exposed to application builder tools.
· Properties —Properties control a Bean's appearance and behavior. Builder tools introspect on a Bean to discover its properties and to expose them for manipulation. As a result, you can change a Bean's property at design time.
· Customization —The exposed properties of a Bean can be customized at design time. Customization allows a user to alter the appearance and behavior of a Bean. Beans support customization by using property editors or by using special, sophisticated Bean customizers.
· Events —Beans use events to communicate with other Beans. Beans may fire events, which means the Bean sends an event to another Bean. When a Bean fires an event it is considered a source Bean. A Bean may receive an event, in which case it is considered a listener Bean. A listener Bean registers its interest in the event with the source Bean. Builder tools use introspection to determine those events that a Bean sends and those events that it receives.
· Persistence —Beans use Java object serialization, implementing the java.io.Serializable interface, to save and restore state that may have changed as a result of customization. State is saved, for example, when you customize a Bean in an application builder, so that the changed properties can be restored at a later time.
· Methods —All JavaBean methods are identical to methods of other Java classes. Bean methods can be called by other Beans or via scripting languages. A JavaBean public method is exported by default.
While Beans are intended to be used primarily with builder tools, they need not be. Beans can be manually manipulated by text tools through programmatic interfaces. All key APIs, including support for events, properties, and persistence, are designed to be easily read and understood by programmers, as well as by builder tools.

yhanglxy 2003-07-09
  • 打赏
  • 举报
回复
JavaBean和C++中的COM类似,而Java Class就是一般的类,类中的方法只能被其定义的对象调用,JavaBean是一个功能完善的模块,可以重复调用,主要用在JSP调用上。两者具体编写没有什么区别,而且都是一个完整的类。
普通的CLASS中没有GETXXX、SETXX方法,多半是不能在JSP中调用,具体情况我没有实践过;而在JAVABEAN中方法基本是SETXXX、GETXXX组成,在JSP中调用很是方便。

81,095

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧