引用 core java 卷二中的原话: 有一节就叫《为什么要使用bean》 8.1 why beans? Programmers coming from a Windows background (specifically, Visual Basic or Delphi) will immediately know why beans are so important. Programmers coming from an environment where the tradition is to "roll your own" for everything may not understand at once. In our experience, programmers who do not come from a Visual Basic background often find it hard to believe that Visual Basic is one of the most successful examples of reusable object technology. One reason for the popularity of Visual Basic becomes clear if you consider how you build a Visual Basic application. For those who have never worked with Visual Basic, here, in a nutshell, is how you do it:You build the interface by dropping components (called controls in Visual Basic) onto a form window. Through property sheets, you set properties of the components such as height, color, or other behavior. The property sheets also list the events to which components can react. For some of those events, you write short snippets of event handling code. 简单点说就是visual basic是世界上最成功的组件重用技术,初级程序员们不需要编写大量的代码就可以轻松的使用它,这样可以把主要的精力放在程序设计,而不是技术实现上,比如在corejava卷一中使用了两页代码实现了一个浏览图片的功能,在vb中只需要5行代码,程序员们不需要在底层代码上浪费时间,只需要连接对象和设计程序 bean就是为了模仿vb这一优点而写出来的,没错,bean是类,in java,everything is class.但是bean超越了一般的class,所以要使用beans注明:上面的中文不是上面英文的翻译,是我的一点理解,最好能看懂english就不用看中文了,免得怡笑大方。
Bean是不是也是类来的?
如果是,那么Bean的好处在那里?
(呵呵,帮楼主你顶)
有一节就叫《为什么要使用bean》
8.1 why beans?
Programmers coming from a Windows background (specifically, Visual Basic or Delphi) will immediately know why beans are so important. Programmers coming from an environment where the tradition is to "roll your own" for everything may not understand at once. In our experience, programmers who do not come from a Visual Basic background often find it hard to believe that Visual Basic is one of the most successful examples of reusable object technology. One reason for the popularity of Visual Basic becomes clear if you consider how you build a Visual Basic application. For those who have never worked with Visual Basic, here, in a nutshell, is how you do it:You build the interface by dropping components (called controls in Visual Basic) onto a form window. Through property sheets, you set properties of the components such as height, color, or other behavior. The property sheets also list the events to which components can react. For some of those events, you write short snippets of event handling code. 简单点说就是visual basic是世界上最成功的组件重用技术,初级程序员们不需要编写大量的代码就可以轻松的使用它,这样可以把主要的精力放在程序设计,而不是技术实现上,比如在corejava卷一中使用了两页代码实现了一个浏览图片的功能,在vb中只需要5行代码,程序员们不需要在底层代码上浪费时间,只需要连接对象和设计程序
bean就是为了模仿vb这一优点而写出来的,没错,bean是类,in java,everything is class.但是bean超越了一般的class,所以要使用beans注明:上面的中文不是上面英文的翻译,是我的一点理解,最好能看懂english就不用看中文了,免得怡笑大方。
从技术上讲,JSP可以实现javaBean的全部功能,但是JSP是设计用做表示层的。一个应用包括表示层以及计算或逻辑处理等,当然最好是拆分表示层和计算或逻辑处理,所以大部分的计算或逻辑处理放在javaBean里了。
1)可以用<jsp:useBean id="aa" scope="" class="package.AA" />标签来申明。然后用aa.set..,aa.get();
2)也可以用package.AA aa = new package.AA();然后用aa.set..,aa.get(); java类在非JSP编程环境下只有方法2,且无scope="page"之内的属性。
这就是Bean规范。
方便导用