JavaBean is divided into visual components and non-visual components, which are mostly non-visual components in JSPs.
JavaBean is actually a class, and there are some rules for writing this class:
- If the member variable of the class is XXX, in order to get or change the value of the member variable, that is, to get or change the property, you must provide two methods: GetXxx () and setxxx ().
- For member variables of type Boolean, it is allowed to replace get and set
- The Access property of a method declared in a class must be public
- The constructor method in the class must be public, without a parameter
Non-visual components include the tool JavaBean and the value JavaBean.
- The value JavaBean strictly follows the JavaBean naming convention, which is typically used to encapsulate form data as a container for information.
- Tool JavaBean can not follow the JavaBean specification, usually used to encapsulate business logic, data manipulation, such as connection to the database, the database to increase, delete, change, check and solve the Chinese garbled and other operations. Tool JavaBean can realize the separation of business logic and page display, and improve the readability and maintainability of code.
Bean byte-code file directory
We all know that a Java program to run, it must be compiled into a bytecode file, and then run by the JVM interpretation, then how can tomcat find this bytecode file?
Tomcat provides a specific directory of files that can be found and executed by the Tomcat server as long as the bytecode file is saved to the directory.
Current project directory: \web-inf\classes, according to the class write the package name, under classes to establish the corresponding directory, the bytecode file in the corresponding directory.
As for the source directory, can be set or not, the general will set up related directories, easy to change the project, the source code storage directory is not what requirements. The source files in eclipse are typically under "project/src".