Naming and role of different packages in Java projects

Source: Internet
Author: User

① defines the Bean class in VO or the domain package, primarily the properties of the class, which is consistent with the fields of a table in the database.

The ②dao package is primarily an interface for manipulating the database to complete the business logic approach.

③dao.impl This package stores such a class, which is mainly implemented in the DAO definition method, complete the specific database operation.

④ in general, the name of the update operation method that executes the database is named in Doxxx (), and the lookup of the database is typically named in the form of findxxx (), GetXXX ().

The ⑤util package is a tool class package that defines the tool class in this package, such as the connection object that gets the operational database

⑥ build a proxy package or service package, define the service class or proxy class in this package, mainly to complete the open and close operation of the database, and to invoke the real implementation class object to complete the business logic operation.

⑦ creates a new factory package that defines the factory class in this package, and its main function is to instantiate the implementation class object and return the object to invoke the method to implement the business logic operation. The factory class ensures that even modifying the methods in a class does not affect other classes when the system is maintained at a later time.

⑧ constructs a exception that defines a class that specializes in handling exception handling exceptions at run time in the system.

⑨ defines a controller package that defines the control classes that are used to specifically handle the steering of the form data, such as logins, Loginservlet

⑩ built a servlet. UI package, which defines the connection requested by the user to a specific link in the form of a servlet.

In order to protect the page, we can put the JSP page into the Web-inf directory, because in this directory the data is hidden outside. And the good habit of writing a implementation class is to pass the JUnit test round, and the test passes the next class.

In the JSP page, in order to avoid the scriptlet script, we can simplify the script code of the page by using the El expression and using the El+jstl method. Note: You can use El+jstl to iterate over the data of list and map passed by the servlet. It is also possible to dynamically get the current site's directory with ${PageContext.request.contextPath}.

Naming and role of different packages in Java projects

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.